DMD 0.170 release

Walter Bright newshound at digitalmars.com
Tue Oct 17 12:13:31 PDT 2006


Jarrett Billingsley wrote:
> "Lars Ivar Igesund" <larsivar at igesund.net> wrote in message 
> news:eh2fl7$2n9g$1 at digitaldaemon.com...
>> Walter, you always say that new features shouldn't be added if they fairly
>> easily can be done with existing language constructs. Now, the post below
>> is about possible new features in D (of general interest and with many
>> possible applications), and it is shown how they can be used to implement
>> an existing (and specific) feature in D. I'm not sure if this should be
>> used as an argument for removing the new delegate-as-aggregate feature, 
>> but
>> it certainly shows that the proposed features have merit.

I think Tom S's proposed new features have merit, but I have to disagree 
that they are better for looping than the new delegate approach.

> While I agree that foreach_reverse seems superfluous with the ability to 
> pass in any delegate as the container, the delegate-as-container is just 
> _too damn cool_ not to implement.  I don't know about you, but I'd rather 
> use a single ampersand than go through all that mixin-in and aliasing just 
> to get it to work.  That, and with the delegate-as-container, you're no 
> longer limited to just class members - you could have just a nested function 
> which you pass in.  Without delegate-as-container, you'd have to create a 
> dummy class with the appropriate mixed-in opApply to get it to work. 

I agree with that. Note that:

	foreach (v; aggr)

is shorthand for:

	foreach (v; &aggr.opApply)

in other words, if you've figured out how to write opApply, you've 
figured out how to write any visitation order, by just changing the name 
of it. As an aside, I've always disliked designs that needed dummy 
classes <g>.



More information about the Digitalmars-d-announce mailing list