[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Thought experiment: what would you remove from Lua
- From: Albert Chan <albertmcchan@...>
- Date: Sun, 9 Sep 2018 09:43:09 -0400
> On Sat, Sep 8, 2018 at 7:25 AM, Axel Kittenberger <axkibe@gmail.com> wrote:
>>> It would break everything, but I'd remove the top-level function keyword
>>> entirely, with the side effects. 2 more keystrokes for `=` in free
>>> functions, plus 4 for `self` in methods.
>> The issue is with recursive functions. You can't do that simply with the
>> "name = function()" syntax.
>
> Is this true? The manual says translation for "local function" is made
> in a certain way to allow self references, and in my machine:
> Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
>> a=function(x) print(x); if x>0 then a(x-1); end end
>> a(3)
> 3
> 2
> 1
> 0
>
> F.O.S.
> ( Note/disclaimer: I like function a(x) better )
it work because a is a global function, not local.