lua-users home
lua-l archive

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

On Tue, Jul 17, 2018 at 10:38 PM Egor Skriptunoff <> wrote:

I am not a believer in Hungarian notation. Making it part of any language is the silliest thing I could think about.
The "Hungarian notation" is just an instrument, it is not a subject to believe or afraid of.
Actually, "Hungarian notation" is one of possible ways to split namespace.
Splitting a namespace might be good or bad, it depends.
IMO, splitting variable namespace into two: globals and locals, would be good in Lua.
Give me as few restrictions as possible on identifiers and if I feel I need a naming scheme, I can create one myself.
No, you can't, because the compiler wouldn't be aware of the naming scheme "created" by you.
For example, if globals in your naming scheme are started with "g_", the compiler wouldn't be able to find your mistake in "local g_var" (global identifier is used for local var).
The compiler also wouldn't be able to detect misspelled local variable name due to "globals-by-default" rule is active despite of your imaginary namespace.
You do need the assistance of the compiler.  That means you need special syntax.

This is all wide off the mark. After a variable is declared, I do not need any "assistance". I do not want the "kind" of declaration to be piggy-backed on a pattern in the declared identifier, either.

If I want to declare something as "global", I want to use a syntax that is not intrinsic to the declared name.

As soon as every variable needs to be declared (within the scope where it is used), one will have to misspell identifiers consistently to avoid compile-time errors. That is a whole new ball game for Lua.

Your proposal, on the other hand, does nothing to deal with misspelled globals: one can happily write \print(), \pront() and \prunt(), \because() \everything() \goes() \after() \the() \magic() \slash()