lua-users home
lua-l archive

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


Fair enough, but the function x(args) syntax is there for the `local
function x(args)` purpose (possible also because it looks nice?)

My guess is that this is the reason. My guess is that the parser most
likely does something like:


x
function x(args)

for non-local declarations of this type. Although, if I'm too lazy to
check, I probably shouldn't speculate. :)

--Andrew

On Sun, Apr 20, 2014 at 6:10 PM, Duncan Cross <duncan.cross@gmail.com> wrote:
> On Mon, Apr 21, 2014 at 12:00 AM, Andrew Starks <andrew.starks@trms.com> wrote:
>> Because the:
>>
>> function x() end
>>
>>
>> Syntax is short for:
>>
>> local x
>> x = function () end
>
> No it's not - you're thinking of:
>
>   local function x() end
>
> Without that "local", it's exactly the same as regular assignment.
>
>
> Anyway, I think it might be an idea worth considering, especially if
> it also came with the optional syntax:
>
>   function :method()  return self.x  end
>
> ....to add the extra "self" parameter.
>
>
> -Duncan
>