lua-users home
lua-l archive

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


Hi Sean,
Sorry for the late reply.

>   I find that odd, because the first parameter to the function is a boolean,
> not a function.

The code I provided is simplified and is triggering argument type error
intentionally, in order to focus on my concern.

>   It's much harder than you think.  What's the name of the following
> functions?
>
>         f = function(a) if not a then error "Bad parameter" end return 1 end
>         g = f
>         h = function(b) if b then error "Bad parameter" end return 2 end
>         i = h
>         x = { y = function() error "There is no name" end }
>
>   Or the name of this function as the second parameter to table.sort()?
>
>         table.sort(array,function(a,b) return a > b end)

"f = function() end" looks like an anonymous function to me.
It would have a name in debugger if it were defined like this:
"function f() end".
I got the point though.
So should I somehow assign a name to my function when I push it
to the Lua stack? Maybe there's a specific way for that?

Thanks for the hints.