lua-users home
lua-l archive

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


> > I would suggest that the syntax should be:
> >
> > <special character><optional name><optional table with only literal
> > keys and values>
> >
> > So assuming your choice of !, we could have:
> >
> > local a!
> > local b !go_to_space { when=true }
> > local c !array { 20 }
> >
> > By allowing an optional table after the name would enable a whole host
> > of possibilities without breaking the lexer / parser I hope.
>
> Personal tastes aside, I fail to see how this differ from the current
> status. These variations would work there, too:
>
> local *a
> local *go_to_space{when=true} b
> local *array{20} c
> local *go_to_space{when=true}, *array{20} myvar = ...
>

Right, sorry I didn't explain fully.
The syntax for annotations should be unambiguous so that they can
appear in multiple places, not just after 'local'.

Taking the example of type annotations, they may appear after function
var names, or as function return value annotation.
They may also appear perhaps in expressions as type cast operators.
Having an unused symbol therefore ensures there are no parsing
conflicts or ambiguities.

I hope this explains why I think * is not a good choice.

I should also clarify that the table I suggested should only allow
literal scalar values, i.e. numbers and strings, as keys and values,
so that the parsing of this is simple.

Regards
Dibyendu