[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Tables without commas
- From: Edgar Toernig <froese@...>
- Date: Wed, 14 Mar 2001 20:53:47 +0100
> For some reason, I wanted to specify tables like this:
>
> myThing = {
> name = "Thing"
> use = "none"
> owner = idPersona
> }
>
> No commas, just like {X,HT}ML attribute lists or anything like that.
This is how it is in Sol (a derivation of Lua), the ',' in the record
field constructor is optional. The only place where it _is_ required
is before a [key]=val field ({ a=b , [foo]=2 }). Without the ','
you'd get a=b[foo]=2 and that will raise a syntax error.
> The only thing people should look out for is stuff like:
>
> a = { strlen "aaa" }
>
> ...which will match the expression and set a[1] to be 4, and *not* to
> function `strlen'. The next does, though:
>
> a = { (strlen) "aaa" }
You get much more problems. Sol requires the ',' in list field parts.
I.e. what's the result of { 1 -2 } or { a (b+c)*d }? (Btw, in Sol your
two examples above would create exactly the same code - it calls strlen
for "aaa" and would give a[1]=3 (not 4!) ;-) IMO the ',' is necessary
in the list fields.
Ciao, ET.