lua-users home
lua-l archive

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


Andrea <andrea.l.vitali@gmail.com> 于2020年5月24日周日 上午1:55写道:
>
>
> Why <const> needs to be a suffix? could it be a prefix with respect to variable name?
> (this would allow to write something like "local const" which looks more natural).
>
> Is there a reason to have opening and closing mark? Or one could get away with something like !close or close! as Philippe was proposing?
>
> Actually I like the use of the exclamation mark as it draws attention to something peculiar.
> (I would use it for <close> which is really peculiar rather than <const> but anyway you get the idea)
>
> Thank you very much for all the answers and comments I got
>
>     Andrea
>
> --
> Andrea Vitali
>
>

Suffix means we can specify different attributes to every local
variables one line.

But I doubt the "<" and ">" symbol: Lua is a language that less use
symbols, we use "if ... then" but not "()", use "do ... end" but not
"{}". Only literals (tables) and expressions (operators) use symbols.
Maybe using an existing keyword for variable attributes is better?

like this:

function readall(filename)
   local fh in close = assert(io.open(filename))
   return thread "*a"
end

We just need change BNF from:
attrib ::= [‘<’ Name ‘>’]

To:
attire ::= ['in' Name]

e.g.
local pi in const = math.pi
local fh in close = assert(io.open(fn))
local const in const, handler in close = a, b

maybe "of" is a better word for keyword (I'm not native English
speaker ), but IMHO the keyword prefixed is better than the symbol
"<>".


-- 
regards,
Xavier Wang.