lua-users home
lua-l archive

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




On Sunday, December 1, 2013, Chris Emerson wrote:
Hi,

On Sun, Dec 01, 2013 at 01:21:41PM -0500, Marc Lepage wrote:
[...]
> ----- BEGIN MODULE -----
> tree = node { node {}, node { node {} } }
> ----- END MODULE -----
>
> So far so good, that is semantically what I want. But I'd like to make the
> syntax simpler, something like:
>
> ----- BEGIN MODULE -----
> node {}
> node { node {} }
> ----- END MODULE -----
>
> where the root level mod.tree node is implicitly made, and the top level
> nodes in the module implicitly add themselves as children to the root level
> node.

You could have all nodes add themselves to the top level, but also have
them remove their children from it.

Chris

That seems like a nice solution. It makes everything consistent and would work for re- rooting branches, if you made the new parent search upward, recursively.