• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: static typing (Learning Cocoa Chapter 13)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: static typing (Learning Cocoa Chapter 13)


  • Subject: Re: static typing (Learning Cocoa Chapter 13)
  • From: Chris Rudolph <email@hidden>
  • Date: Fri, 21 Sep 2001 15:07:43 -0700

This simple and more elegant solution is to NOT declare multiple variables on the same line.

- Chris.

On Friday, September 21, 2001, at 02:09 PM, Erik M. Buck wrote:

In the name of aesthetic flame wars:
The asterisk indicates that a variable is a pointer not that a type is a
pointer. The asterisk therefore belongs with the variable and not the type.

The simplest highlight of that fact follows:

char *foo, bar, *baz;

foo is a pointer (probably 4 bytes)
bar is a character (probably 1 byte)
baz is a pointer (probably 4 bytes)

If the pointerness was part of the type then

char* foo, bar, *baz;

would make foo a pointer, bar a pointer, and baz a pointer to a pointer
which is of course wrong and ludicrous.


----- Original Message -----
From: "John Pannell" <email@hidden>
To: "Cocoa Developer" <email@hidden>
Sent: Friday, September 21, 2001 2:36 PM
Subject: Re: static typing (Learning Cocoa Chapter 13)


Just to add an extra tidbit... the asterisk can appear _appended_ to the
type, or _prepended_ to the variable. For example:

NSButton* myButton file://right
NSButton *myButton file://also right
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev

--
Chris Rudolph, AppleWorks Engineering
Apple Computer, Inc.
email@hidden


  • Follow-Ups:
    • Re: static typing (Learning Cocoa Chapter 13)
      • From: Ondra Cada <email@hidden>
References: 
 >Re: static typing (Learning Cocoa Chapter 13) (From: "Erik M. Buck" <email@hidden>)

  • Prev by Date: NSTask / NSPipe / FTP
  • Next by Date: Re: static typing (Learning Cocoa Chapter 13)
  • Previous by thread: Re: static typing (Learning Cocoa Chapter 13)
  • Next by thread: Re: static typing (Learning Cocoa Chapter 13)
  • Index(es):
    • Date
    • Thread