lua-users home
lua-l archive

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


On Wed, Aug 12, 2009 at 2:13 AM, Asko Kauppi wrote:
> The idea is that Lua syntax is a bit nicer to craft than XML, but this also
> allows programmatic creation of macro-like objects (functions that create
> graphical objects) that can be turned around, copied etc.. SVG has a "uses"
> element for that, but this is more easy on the eyes (clearer code).

On Sun, Aug 16, 2009 at 4:45 AM, Stuart P. Bentley wrote:
> I've also written a modeling framework that works almost exactly like this! ....
> (This gets passed to a function "model", which uses as an environment a
> table of primitive-generating functions.

There's a number of ways to design this [1,2], and some ways can be
expressed in terms of wrappers around other ways.  I've been tending
to settle on Asko's style, which avoids the function and environment
(which has undesirable qualities like locals outside the function
overriding environment variables and environments complicating static
methods of detecting undefined variables [3]).  As Asko mentioned, the
Lua structure is somewhat like XML, and in that way it can be made to
work like pure data provided you don't intersperse other Lua
constructs into it (which unfortunately complicates clean round-trip
serialization).

[1] http://lua-users.org/wiki/LuaDataFormats
[2] http://lua-users.org/wiki/TableScope
[3] http://lua-users.org/wiki/DetectingUndefinedVariables