lua-users home
lua-l archive

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


Albert:

On Sun, Sep 9, 2018 at 3:43 PM, Albert Chan <albertmcchan@yahoo.com> wrote:
>> 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
...
> it work because a is a global function, not local.

I should have explained myself better:

I DID NOT made an example for local because:
1.- it would need a nested function in the unmodified command line
environbment I use ( local does not work right in the repl ).
2.- Manual explicitly says it shuld work, so if it doesn't it is just
a bug to be reported.

I did make an example for global because:
0.- I was unable to find a paragraph stating it should as directly as
3.4.11, my knowledge of how globals are just entries in a magic hash (
a => _ENV.a or _G.a ) pointed it should do ( you can even do mutual
recursion to a to be defined function in globals, and even do a calls
b ( not defined ), b calls c ( not defined ), set c=a, it know works,
but I felt the example was better ).

And in the discussion I was trying to rply to they where talking about
all uses of function, not just locals or globals.

Francisco Olarte.