lua-users home
lua-l archive

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


On Tue, Aug 03, 2004 at 01:34:08AM +0300, Asko Kauppi wrote:
> 
> I was trying around and noticed this can be done:
> 
> 	return ({ [0]="yes", [1]="no" })[ rc ]
> 
> ..but this not (had tried before):
> 
> 	return { [0]="yes", [1]="no" }[ rc ]
> 
> Is there a syntactical reason, or is it just an implementation detail?

You're aware of the kludge that prevents you putting a newline before
the ( when calling a function? Allows table constructors to be
prefixexps would have exactly the same problem, e.g:

   -- One statement or two?
   x = f
   { ... }[i]()

Except it's more likely that you'd want a newline there, e.g.

   some_configuration_directive
   {
       ...
   }

-- Jamie Webb