lua-users home
lua-l archive

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


On 16/08/2011 0.07, Axel Kittenberger wrote:
[...]

Language differences go deeper than superficial syntax like this. It
are the subtleties that make or break a language (undefined vs. nil,
paramter lists, etc.). I like the idea doing some "preprocessors" to
change the superficials to fit ones needs.

A good thing if programs are intended for very limited circulation (one developer's custom scripts/tools; a very small dev group), otherwise (IMHO) it brings some relevant documentation burden if it is to be done realiably (or code exchange will get messy and you'll end up exchanging code bugs with people communication bugs - which are nastier, IMO).


[...]

Local or global default also raised tons of discussions. I tend with
one conclusion: I don't see why there should be anything default. What
are few characters vs. hours of fun endless debugging? Anyways this
"if the name already exists uses global otherwise local, is very
unfortunate as soon the project grows over the few demolines of
impressing expressiveness all the languages have to feature on their
frontpage.

From a general programming POV, I agree heartily: I really wouldn't mind typing also a "global" keyword in front of the very few globals I use normally.

The problem is with Lua-based DSLs, which are IMO a fantastic tool. With a "global" declaration enforcement rule, they'll become a pain.

This is a place where some customization/parametrization of the compilation process would come handy. For example, it would be nice to being able to say to the loadfile/loadstring function to raise an error whenever an undeclared identifier is used:


-- for "true programs"
local options = { signal_undeclared_globals = true }
loadfile( "myprog", options )

-- for DSL (current default)
local options = { signal_undeclared_globals = false }
loadfile( "myprog", options )

then also a "default compiler options" setting function:

setoption("signal_undeclared_globals", true)

so that any subsequent load/loadfile/loadstring could use that settings.

In this way the default Lua program could also be made stricter, by enforcing "global" declarations without hampering the ability of creating DSL files.

cheers
--Lorenzo