lua-users home
lua-l archive

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


On Friday 25 February 2005 19:55, Aaron Brown wrote:
[...]
> This special case exists for literal strings and table
> constructors to make Lua more flexible as a data-description
> language:

In fact, I'd rather like to see this syntax kept, but generalised, so that 
'print true' does actually work.

This opens up the possibility for some rather nice features by chaining 
together functions.

Object = {...description of object...}

o1 = Object
o2 = green Object
o3 = large green Object
o4 = sparkly large green Object

...where green, large and sparkly are functions that take a single parameter, 
examine their contents, and return a new table based on those contents. 

Terribly handy, particularly for a data description language, and has the 
bonus that it would make the language more consistent, which means a less 
complex and therefore smaller parser.

Imagine this applied to LTN12, for example.

(However, you would have to be extremely careful with precedence, and it opens 
the door for some unpleasant typo-based bugs. 'foo() + bar()' and 'foo() 
bar()' become valid, the latter being equivalent to 'foo()(bar())'.)

[...]
> All of the libraries, including io, use the dot notation.
> The io library (the only library that deals with handles)
> also uses the colon notation when a handle is involved.

Yes, : is completely appropriate here.

-- 
"Curses! Foiled by the chilled dairy treats of righteousness!" --- Earthworm 
Jim (evil)