lua-users home
lua-l archive

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


On Thu, 25 Apr 2019 at 18:53, Diego Nehab <diego@impa.br> wrote:
>
> I am curious about what happens after the syntax has been settled. I can see how these generalized annotations would be set from the C side, perhaps by a generalized "lua_toclose" function. But how would the C side control the meaning of these annotations? Can the C side even check the value of annotations set from the Lua side? Must all annotations be associated to their own metamethod that receives a table with the additional parameters? Are there other examples of useful things to do with these annotations in Lua, besides block-scope finalization?

Hi, I think my main concern right now is that a new syntax '*toclose'
is going to be introduced, for a very specific use case. I do not
believe it has yet been fully explored as to how this would be an
extensible syntax in the future. So then it means that Lua will be
stuck with this syntax for good or bad for years to come. As Roberto
says it is easy to add something, hard to take it back.

It is better to take some time and think through if a generic
annotation feature can be introduced of which '*toclose' becomes a
part. This will pay off in the long term.

Alternatively if there isn't time to do that, then drop the '*toclose'
feature ... better not have it than be stuck with a syntax that may
not serve Lua in the long term.

So the first concern is:

a) Is this going to be something generic or very specific?
b) If generic then can it be something that allows other annotations
to be used in a meaningful way? This can vary between saying an
annotation is simply a symbol+name, or it is something more rich -
symbol+name+table as I suggested.
c) The semantics of this needs to be defined; i.e. where can
annotations appear? In my view to be useful they should be allowed at
every name declaration, and possibly also in expressions.
d) What does Lua do when it encounters an annotation it doesn't
recognise? If it doesn't handle such annotations gracefully then it
will not be possible for any annotations to be used other than
predefined ones such as '*toclose'.

I think the secondary question is what happens to the annotations.

Clearly one option is for Lua to just ignore them in general, and for
third-party tools to write pre or post processors to handle these
annotations.
Another more powerful option is to save the annotations and make them
available as metadata at runtime - but I am not sure if we need to go
this far.

As for immediate benefits, I think that several initiatives are trying
to add type annotations to Lua; this will allow Lua to handle code
that contains such type annotations, and for these other
implementations to happily coexist with Lua.

Regards
Dibyendu