lua-users home
lua-l archive

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


On Fri, 7 Jun 2019 at 23:56, Hisham <h@hisham.hm> wrote:
> Allowing the annotation to be prefixed to the
> entire `local` declaration
> (made possible by the unambiguous @ syntax), one could do the more natural
>
>    @my_custom_annotation(with, arguments)
>    local function my_local_function()
>       -- ...
>    end
>
> Given that `local function f` is already a syntactic shorthand to
> `local f = function`, I guess `@annotation local function f` could be
> a syntactic shorthand to `local @annotation f = function`.
>

Prefixing an entire local statement would imply the annotation applies
to all names declared in that local statement. I would argue that
annotations should be allowed per variable name, hence they should
suffix or prefix a variable name.
We should also think about allowing annotations in function parameters
... although not needed right now, a syntax that supports this in
future would be nice.

The advantage of '@' prefix is that it can introduce an annotation in
any context - even in expressions.

Regards