[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: future of annotations in Lua?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 7 Jun 2019 11:10:22 -0300
> [...]
> that using '<' like that would introduce ambiguites that would
> preclude general function annotations in the commonly-adopted
> annotation style. The following would be hard to parse without
> significant lookahead:
>
> local x = y
>
> <my_custom_annotation(with, arguments)>
> function my_global_function()
> -- ...
> end
>
> If the door is to be left open for such a generalized mechanism in
> future versions of Lua beyond 5.4, then adopting a syntax based on an
> unused token such as @annotation would be advisable. Matching the
> annotation syntax of other languages would be a side benefit.
There is a big difference between all those syntaxes and the one
we are using in Lua, not because of the peculiarities of '<name>'
versus '@name': They are all prefixed to the whole item to which they
apply. Following their syntax, we should write '@toclose local x = 1',
instead of 'local @toclose x = 1'.
For locals it is not a big difference, but the following looks weird to
my eyes, no matter the details:
@my_custom_annotation(with, arguments)
function my_global_function()
-- ...
end
Maybe it is a consequence of Lua not having explicit statement
termination, but I do not visualy associate the attribute to the
function. They look like two independent statements. (BTW, note that
the C++ [syntax] in Lua would have the same problem that <name>,
assuming prefixed attributes.)
-- Roberto