On Thu, Apr 25, 2019 at 9:38 AM Dibyendu Majumdar wrote:
I would suggest that the syntax should be:
<special character><optional name><optional table with only literal
keys and values>
So assuming your choice of !, we could have:
local a!
local b !go_to_space { when=true }
local c !array { 20 }
By allowing an optional table after the name would enable a whole host
of possibilities without breaking the lexer / parser I hope.
A little improvement: arguments for an annotation must have free syntax.
I suggest to allow arbitrary text with the only limitation: if such text contains curly braces, they must be balanced.
local ver_num @type{int16} @const = 0x504
local arr @autoclose = {} @size{10}
local dict = {} @size{hash=1000}
local function add(x, y)
@type{in = {int32, int32}, out = {int32}}
@asm{add EAX,EDX / ret}
return x+y
end
for j = 1, 256 do @parallel{4}
end
But there is an ambiguity with such syntax:
What does
local x = my_func @inline {1} ()
mean:
local x = (my_func @inline) {1} ()
or
local x = my_func (@inline {1}) ()
?
There must be documented way to syntactically distinguish whether each "annotation invocation" has arguments or not.
The compiler must correctly extract and ignore unknown annotations.