lua-users home
lua-l archive

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


Roberto Ierusalimschy wrote:
> But if you try
>
>   function foo(x,y,z).x (a,b,c)
>   end
>
> the parser would have a hard time to realize that (x,y,z) is not the
> parameter list of the function.

I don't need the full sugar (the embedded function call), just one more teaspoon to cover a very
common case:

    function mylib.MyClass:method() ... end

Let's try the "accepted syntax":

    -- oops, you can't do this!
    mylib.MyClass:method = function() ... end

So now we're down to:

    mylib.MyClass.method = function(self) end

Which makes it very hard to identify class members functions in your code, even with syntax
highlighting.  And you've lost the method definition sugar.

The "temp variable" workaround is the worst looking of all, and defeats trying to keep
everything inside mylib:

    local temp = mylib.MyClass
    function temp:method() ... end

Please consider Edgar's function definition extension for Lua.

Thanks,
-John