lua-users home
lua-l archive

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


This means, in the above syntax, that the two top level nodes have to add themselves to the implicit tree root node, but the child node must not do that.

As others have shown, this is certainly doable, provided you're willing to track and maintain a few supplemental datastructures.  But it feels unnecessary.  What are we gaining by attaching two different semantics to a single function name?  Why not use a tree configuration file like:

  add_node {}
  add_node { node{}, node {}  }

It might actually be easier to read, and it would certainly be simpler to implement.

Over-optimizing for simple syntax can be every bit as dangerous as over-optimizing for computational efficiency.  And I'll admit that that's a lesson I've had to learn from personal experience :-P

-Sven