lua-users home
lua-l archive

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


On Sat, Jul 20, 2013 at 12:38 AM, Greg Fitzgerald <garious@gmail.com> wrote:
I wonder if Lua might consider adding a __method metamethod, which
could be used for OO programming and as an alternative to the colon
operator.

But ... we're all used to the colon operator, and we know what it does. We avoid any weird magic and implicit generation of partial functions.  However, I'm partial to 'm:foo' on its own meaning partial application, as it is in Moonscript.

Now, I've always thought that the use of something like __method is to distinguish between things which actually are methods and things which are fields. So when writing a Set class which has a 'add' method, we don't get false positives like 's["set"]` being true.  (in the Penlight Set 'class', the solution was not to use methods but overload the usual operators and provide some functions to operate on sets)

steve d.