lua-users home
lua-l archive

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

It was thus said that the Great Dibyendu Majumdar once stated:
> On Thu, 25 Apr 2019 at 06:54, Dirk Laurie <> wrote:
> >
> > Op Do. 25 Apr. 2019 om 03:33 het Philippe Verdy <> geskryf:
> > > I also agree that the "*xxx" or "*(xxx, params...)" syntax is very fuzzy and will not work with the future evolution of annotations
> > >
> > > Le jeu. 25 avr. 2019 à 00:22, Dibyendu Majumdar <> a écrit :
> > >> I am writing about this again in the hope that it is not too late to
> > >> change the syntax of the *toclose attribute. I think there is an
> > >> opportunity to allow a general way of introducing annotations in Lua,
> > >> which can be exploited by extensions. It would be sad if that
> > >> opportunity is lost.
> >
> > Therefore I would suggest that an annotation starts with ! and
> > continues until but not including the first termination character.
> > Sensible termination characters might be comma, semicolon and end-of
> > line, allowing annotations for every item in a parameter/return list,
> > table constructor etc, but not encumbering the parser with a difficult
> > decision whether the annotation is done. In the contex of "local", an
> > empty annotation could default to 'toclose', so that "local a!, b, c!`
> > is all that one needs to supply "toclose" directives.
> >
> I would suggest that the syntax should be:
> <special character><optional name><optional table with only literal
> keys and values>

  So I'm looking at Java because they now have annotations.  From a cursory
look, it appears the syntax to be:

	'@' ID

  So things like


  Annotations can be used at development time, compile time or runtime [1]. 
They can also be targetted towards a particular usage [2].  In Java, custom
annotations are handled with creating an interface.

  Assuming we use something similar to Java, the "to-close" annotation of
Lua 5.4 could probably look somthign like:

	function @to_close(var)
	  -- whatever this does

	  local @to_close file =
	  lcoal @to_close obj  = custom:blah(...)
	  -- code code code
> So assuming your choice of !, we could have:
> local a!
> local b !go_to_space { when=true }
> local c !array { 20 }

  Well ...

	local @my_annotation a
	local @go_to_space { when = true } b
	local @array(20) c

where '@array' is a special function called with certain parameters
depending on what it's targetting and any parameters given to it.  Too
magical?  Not magical enough?  Too much like Java? I don't know, it's
beginning to look a bit heavy to me.