A syntax option (function types versus arrays)
alex.blewitt at gmail.com
Thu Mar 11 00:09:51 PST 2010
On 11 Mar 2010, at 07:50, Gernot Neppert wrote:
>> A possible alternate syntax is:
>> #< R( A ) throws E > example = new #< R( A a ) throws E >( ... );
> I like the following two things about this syntax:
> firstly, the use of "new" to create a lambda. This makes it consistent
> with other object instantiations (in this case, an object of function
> type being created).
However, it precludes the compiler from being able to optimise out instance creation in the case that the lambda is constant (or doesn't capture/use local state) since 'new' is defined semantically and by general understanding to create a new instance every time.
What you really need is some kind of 'factory' that can either return you the same instance or give you a fresh instance each time depending on the circumstances. Enforcing an always-creation model would be a significant disadvantage for the kinds of filters (like 'even') which would not change each time.
More information about the lambda-dev