[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Globals vs. Locals
- From: Romulo Bahiense <romulo@...>
- Date: Thu, 04 Aug 2005 16:16:15 -0300
(...) Delphy have no default, although if you say nothing inside the function
the variable can yet be global but cannot be local, so they seem
nearer to a "global by default". Perl and JavaScript have global by default.
Hmmm.. I really don't want to be boring, but.. The name is Delphi, and
the language is Pascal (or better: Object Pascal, not the old Turbo
Pascal). Delphi is for Pascal what Visual Studio is for C[1].
About the scoping:
In Delphi: If you don't declare a variable inside a function/procedure,
it could be:
- A global variable;
- A class/record/etc member (field);
- A global variable from another unit;
In case of name collision, the compiler will choose the nearest
declared/visible (I think it is the same behaviour of C).
In Lua: In the beggining I thought it was boring having global by
default, but then I got used to type 'local' and I'm quite happy now,
specially because it is faster :)
--rb
[1] I'm really (really!) sorry, but a lot of people think that Delphi is
the language, and it is interpreted as Visual Basic. Both are wrong.