[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: first class ':'
- From: Eduardo Ochs <eduardoochs@...>
- Date: Wed, 16 Sep 2009 13:41:20 -0300
On Tue, Sep 15, 2009 at 5:17 AM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> On Tue, Sep 15, 2009 at 10:00 AM, David Kastrup <dak@gnu.org> wrote:
>> But I like the things that are just syntactic sugar in Lua: it means
>> that you can exhaustively explain them in more basic terms in one
>> sentence.
>
> OK, this is sugar we know so well:
> - obj:method() becomes obj.method(obj)
>
> But in the case of a obj:method _without_ parentheses, then there is a
> somewhat more elaborate expansion as a closure.
>
> That feels manageable.
>
> First-class ':' has some cute advantages, it is an operator and
> presumably has a metamethod, so that we can finally distinguish
> between method and table lookup, _if needed_.
>
> But I worry about the complexity of the change, possible performance
> implications, and more semantics that, yes, have to be explained ...
What about this idea?
When functions have a metatable and when that metatable has a field
"__colon", then the expression
f:method
without an argument list, of course, would just return the result of:
getmetatable(f).__colon(f, "method")
Cheers,
Eduardo Ochs
eduardoochs@gmail.com
http://angg.twu.net/
- References:
- Regarding the name 'pairs', TNHarris
- Re: Regarding the name 'pairs', TNHarris
- Re: Regarding the name 'pairs', TNHarris
- Re: Regarding the name 'pairs', Miles Bader
- Re: Regarding the name 'pairs', Luiz Henrique de Figueiredo
- Re: Regarding the name 'pairs', steve donovan
- Re: Regarding the name 'pairs', Roberto Ierusalimschy
- Re: first class ':', froese
- Re: first class ':', David Kastrup
- Re: first class ':', steve donovan