[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: future of annotations in Lua?
- From: Lorenzo Donati <lorenzodonatibz@...>
- Date: Thu, 6 Jun 2019 23:34:54 +0200
On 06/06/2019 22:41, Hisham wrote:
A pattern in Lua's history is that some features appear first as a
special-case feature that solves a narrow set of problems, and are
later generalized into a broader mechanism.
[snip]
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.
-- Hisham
I fully agree!
As I wrote in another thread (in a sub-sub thread - urgh! this 5.4 thing
is stirring lua-l quite a lot :-) compare:
local <toclose, static, nice, helpful, wonderful> resource = ....
vs.
local @toclose @static @nice @helpful @wonderful resource = ....
and also regarding code hard wrapping:
local < toclose, static,
nice, helpful, wonderful > resource = ....
vs.
local @toclose @static
@nice @helpful @wonderful resource = ....
The more I think about it, the more I find the syntax with "@" more
readable and more easily "expandable": parametrized annotations anyone?
Like for example:
local @const myTable = @table(64) {} -- preallocates 64 elements in the
array part
BTW, as for naming, I'd prefer to call them "attributes" more than
"annotations". The latter conveys the idea that the "annotation" doesn't
change the semantics of the code, whereas "attribute" gives a more
general idea of "something that gives additional characterization".
My 2 EURcents! :-)
Cheers!
-- Lorenzo