lua-users home
lua-l archive

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


{ snip }
Both things are not totally unrelated, unfortunately.  Lua has proper
lexical scoping, and each file ends up in its own chunk.  So when you
write

     local x = 1

in one file, it only affects that scope.  It works as expected if you
drop the "local".

I think it will be possible in Lua 5.2 to use the "debug" library
("upvaluejoin" in particular) to obtain the effect you desire.
I'm not sure if that's a good idea, though.


Thanks Florian

That's a good point about local, in another file it means local to that file.

List,

This problem with sharing code seems very complex and I am sure due to the fact that it must include C modules too it is not easy at all.

Having said this the language is billed as being suitable for non-programmers. Please see page 156 of PIL:

""typically developed by one or a few programmers or even by non-programmers""

Since this is the case I think mechanisms for non-programmers should be of high importance. Module/require/dofile are very subtle and confusing, PHP-dumb include is not.

All language features do not have to be used by all, why not just add a php-dumb-include that overrides local, as in local to that file for non-programmers and bill the other mechanisms as to be used by advanced users?