[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Popularity contest
- From: Mark Hamburg <mark@...>
- Date: Mon, 26 Sep 2011 23:16:38 -0700
On Sep 26, 2011, at 12:06 AM, steve donovan wrote:
> A little consistency: we know that f:method has no meaning as an
> expression. It has been suggested that it can be given a consistent
> meaning as function(...) return f:method(...) end, that is, it is a
> closure over the self parameter. This is convenient for the common
> case of providing callbacks which are methods of some object.
Definitely convenient.
The other thing I find myself wanting is:
obj:[ method_expr ]( ... )
as syntax for obj[ method_expr ]( obj, ... ).
This is useful when you need to compute the method to invoke. It has the benefit of avoiding the need to make sure you stick obj into a local variable to avoid double-evaluation. It also opens up the possibility that at some point in the future, colon might become a "real" operator and not just syntactic sugar.
This is actually easier to implement than obj:method as a way to create a closure since it mostly just takes as I recall some small parser revisions and a slight revision to OP_SELF.
Mark