lua-users home
lua-l archive

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

Would be nice have conception of namespace. Namespace always global, in every programming language.

Code can look like:

namespace MyNamespace
   a = 1

   function fn1()

and if I load code as package, I can access to "a" or function:


On Wed, Jul 4, 2018 at 4:31 PM, Viacheslav Usov <> wrote:
On Wed, Jul 4, 2018 at 10:10 PM Egor Skriptunoff <> wrote:

> Or did you mean "$ is ugly because it looks too Perl/PHP-ish"?  :-)
> Does "@" look more esthetically than "$"?

I am not a believer in Hungarian notation. Making it part of any language is the silliest thing I could think about. Give me as few restrictions as possible on identifiers and if I feel I need a naming scheme, I can create one myself, thank you very much. 

> Declaring each used global in special global-declaration-statement is boring.

You could substitute 'local' for 'global in your statement, and it would be equally pointless. What is more, your proposal is squarely about declaring each and every global. But why should it be easier to declare globals than locals?

Any code that needs a large number of globals is suspect unless there are special circumstances warranting that; if that is the case, not local = implicit.
> When you want to determine whether this variable is global or not, you have to search for global-declaration-statement that may be located far from the current line. 

That sounds as if that were something of utmost importance. But, again, why is that more important than having to decide whether a given local is an upvalue, or a plain local, or whether it eclipses another local? Also, see above re naming schemes.