Re: Future Objective-C changes
Re: Future Objective-C changes
- Subject: Re: Future Objective-C changes
- From: Andy Lee <email@hidden>
- Date: Wed, 21 May 2003 11:57:45 -0400
At 4:51 PM +0200 5/21/03, Marcel Weiher wrote:
I have never ever heard anyone refer to "defining" a local variable,
though that doesn't mean it has never happened.
I think someone pointed this out, but "declare" and "define" have
very specific meanings in C. The key distinction is not between
local vs. global variables. It is between announcing ("declaring")
the existence of a variable name (meanwhile specifying the data type
of the variable) vs. telling the compiler to allocate a memory
location for it ("defining" it).
A local variable declared like this...
{
int localInt;
...
}
...is defined at the same time, by the same statement. It *has* to
be, because by definition the memory allocated for a local variable
is freed when the variable's scope is exited. So it wouldn't make
sense to talk specifically about "defining" a local variable; it goes
without saying. *That* is probably why you have never heard anybody
say such a thing, not because there is different terminology for
local and non-local variables.
As another example of the distinction: a non-local variable can be
declared multiple times, but it can only be defined once. You can
say this...
extern int globalInt; // declaration
...as many times as you want, but you must say this...
int globalInt; // definition which is also a declaration
...exactly once.
--Andy
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.