lua-users home
lua-l archive

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


Em qui, 20 de jun de 2019 às 11:58, Lorenzo Donati
<lorenzodonatibz@tiscali.it> escreveu:
>
> On 20/06/2019 12:36, Rodrigo Azevedo wrote:
> > Em Qui, 20 de jun de 2019 02:40, Egor Skriptunoff <
> > egor.skriptunoff@gmail.com> escreveu:
> >
> >> On Fri, Jun 14, 2019 at 11:22 PM Viacheslav Usov wrote:
> >>
> >>> This is probably bikeshedding, but:
> >>> local (x scoped), (y const), (z const alias) = a, b, c
> >>>
> >>>
> >>
> >> This is a nice bikeshedding!
> >> From aesthetic point of view, it looks more pleasant than other possible
> >> syntax such as <const>, @const and :const
> >>
> >
> > +1
> >
> > As a 'per Name' syntax, but 'scoped' is not a good word.
> >
> >
>
> Yep, but a little better than "toclose", IMO (and the related metamethod
> could be named as "__scope_handler", for example, which is more readable
> and explicit than "__close").
>
> Actually it would be nice if someone could come up with a word that coul
> express the real concept clearly. For example: "at_scope_end" (or and
> "__at_scope_end" as a metamethod. Of course those are UGLY.
>
> Maybe "atend"? It's more explicit than "toclose" since actually
> describes that something happens when execution flow reaches the "end"
> keyword. "__atend" is not bad as a metamethod.
>
>
> > Maybe, it could be extended to a 'per type' 'local'
> >
> > (local const) x, y, z =...
> >
> > Where x, y and z are all 'const'.
> >
>
> Mmmh, here the syntax is getting really messy.

Could be messy,  but useful also.
If each reserved word could be 'annotated' with the syntax
( reserved_word annotation1 annotation2 etc )
such that almost everything after 'reserved_word' can be
simply ignored by standard Lua, with the exception of some 'const' and
'close' related things,  then we could write

(local const) ten = 10

mysqrt = (function integer integer) (a,b)
        (return number) math.sqrt (a*a + b*b)
end

(local my awesome annotation) x,y = 4,5

(local integer) x = 0
(for unroll 4 parallel) i=1,10 do
        x = x+i
end

(do parallel) something() end
--

It is not so ugly. It is readable and Lua has very few keywords
that can be easily parsed by anyone, including a simple
'remove all' for compatibility with previous versions.

 We can even write a simple personalized preprocessor
and also keep the source compatible with standard Lua.




















-- 
Rodrigo Azevedo Moreira da Silva