lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Petite, It looks like I have replied to you before, but I figured that
it would be fair to explain my point a little bit further:

On Sun, Oct 9, 2011 at 11:32 PM, Petite Abeille
<> wrote:
>> are way too often
>> unknowingly overwritten,
> Is that so?

Unfortunately, when I've learned Lua i managed to overwrite 'arg'
unknowingly, by doing something pretty harmless:

     for arg in pairs(args) do

And '_VERSION' when I wanted to give my module a version.
Of course that happened a many moons ago, so i've naturally learned to
take better care :-)

>> because neither '_VERSION' nor 'arg' are in
>> any way especially marked.

I mentioned that due to my experience with other languages:

   in C/C++/C#/Java/Erlang, the 'commandline argument vector' is
usually passed to the main function.
   in Perl, argv is declared as '@ARGV' (note that it's uppercase)
   in Ruby, argv is declared as a constant symbol named ARGV (again, uppercase)
   in python, argv is available through the 'sys' module, which has to
be imported manually


in C/C++, the compiler version can be accessed through the
preprocessor, independently from the language
in C#/Java, the compiler version and runtime version are accessibly
through special environments ('properties' in Java)
in Python, the version is, again, accessible through the sys module
in Ruby, the version information is declared in constant symbols,
respectively prefixed with 'RUBY_', for example, 'RUBY_VERSION' for
the version of the virtual machine
in Perl, the version is stored in a magical variable called '$]', for
example 'print $];' would yield '5.010001' on my machine.

All these languages encapsulate such data in a way that reduces
'accidental' overwriting of the argument vector variable, or version
information. Some languages make the argument vector and/or version
readonly (Java does that, if i'm not mistaken).

Again, the idea here is nothing new, and usually known as
'namespacing' and modularity.