lua-users home
lua-l archive

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


re,

well. small improvement for someone interested in

function() a=a+1 return a end — <? a=a+1 -> a ?> 
function(b) a=a+1 return a+b end — <?(b) a=a+1 -> a+b ?> 
function() a=a+1 end — <?a=a+1?>

Attachment: lua-5.4.3-short-funcs.patch
Description: Binary data


> On 8 Oct 2021, at 17:28, Paul K <paul@zerobrane.com> wrote:
> 
>>> good for small functions passing as parameter. the idea is that list in {{ }} returns the last calculated expression (or the list)
>> both are worse
> 
> There is "Short Anonymous Function" syntax page
> (http://lua-users.org/wiki/ShortAnonymousFunctions), which includes
> "do end" power patch for functions
> (http://lua-users.org/wiki/LuaPowerPatches) and short anonymous
> function syntax (http://lua-users.org/wiki/LuaPowerPatches), like
> |param| param + 2. The latter is also implemented by GSL shell
> (https://github.com/franko/gsl-shell) and LuaJIT lang toolkit
> (https://github.com/franko/luajit-lang-toolkit).
> 
> Paul.
> 
> On Fri, Oct 8, 2021 at 3:04 AM eugeny gladkih <john@drweb.com> wrote:
>> 
>> 
>> 
>>> On 8 Oct 2021, at 09:49, Robert Burke <sharpobject@gmail.com> wrote:
>>> 
>>> Hello,
>>> 
>>> Indeed, the syntax proposed is currently valid:
>>> 
>>>> a = setmetatable({}, {__call=function(_,x) print(x[1][1]) end, __add=function(a,b) return b end})
>>>> (a){{ a + 2 }}
>>> 2
>> 
>> JS way:
>> 
>> (a) => a + 2
>> () => b + 2
>> => b+2
>> 
>> LISP like
>> 
>> ` b+2
>> (a) ` a+2
>> 
>> both are worse
>> 
>>> 
>>> On Thu, Oct 7, 2021 at 6:59 PM Spar <developspartv@gmail.com> wrote:
>>>> 
>>>> Your syntactic sugar basically adds entirely new syntax which is not used anywhere in language. These {{ }} are crazy and ambiguous
>>>> On 7 Oct 2021, 12:56 +0300, eugeny gladkih <john@drweb.com>, wrote:
>>>> 
>>>> hi,
>>>> 
>>>> what about funny syntax sugar for functions definition, lazy people are welcome to upvote
>>>> 
>>>> function( a ) return a + 2 end -> (a){{ a + 2 }}
>>>> function() do-something end -> (){{ do-something }}
>>>> {{ do-something }}
>>>> 
>>>> good for small functions passing as parameter. the idea is that list in {{ }} returns the last calculated expression (or the list)
>>>> 
>>>> --
>>>> Yours sincerely, Eugeny.
>>>> +33 6 38 52 27 93
>> 
>> 
>> --
>> Yours sincerely, Eugeny.
>> +33 6 38 52 27 93


-- 
Yours sincerely, Eugeny.
+33 6 38 52 27 93