[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Is Lua used as a data representation language?
- From: William Ahern <william@...>
- Date: Sat, 5 Jan 2013 20:41:41 -0800
On Sat, Jan 05, 2013 at 05:48:22PM -0500, Javier Guerra Giraldez wrote:
> On Sat, Jan 5, 2013 at 3:01 PM, William Ahern
> <firstname.lastname@example.org> wrote:
> > Although, autovivification
> > is very nice in a configuration language, and Lua can't quite manage it,
> > unfortunately.
> if i understand correctly, you mean the ability to write:
> a.b.c = 5
> and getting
> this is sometimes called "automagical tables", or tables on demand,
> and there's a simple implementation of this written long ago in the
> wiki: http://lua-users.org/wiki/AutomagicTables
I'm not sure that works like in Perl. It works for writing, but not reading
AFAICT. In the example above, in order to get a.b.c = 5 to work, evaluating
a.b must return a table. So would a.b.c if all you were doing was checking
the value. So in Lua a.b.c would return a table, instead of undef as in
So get full autovivification, the expression evaluator has to know more
information about the full expression than is available to a metatable.