foreach, an analogy

Bill Baxter dnewsgroup at billbaxter.com
Wed Oct 18 20:43:13 PDT 2006


Gregor Richards wrote:
> Bill Baxter wrote:

> The bigger door is 'for'.  'foreach' is nothing but a convenient wrapper 
> around 'for'.  And don't you OOphiles go telling me that your fancy 
> class foo that has iteration /needs/ 'foreach':
>   for (auto bar = foo.begin(); !(bar is null); bar = foo.iterate(bar))
> Is it less pretty than foreach?  Yeah.  That's why foreach exists. 

:-)  Heh heh.

> But 
> don't go saying that the reverse foreach is a band-aid patch, because
> both forms are just convenience wrappers around the far more powerful 
> and useful 'for'.  

Yeh, for is like a piece of wood.  You can do anything with it. 
Including make a door.  But sometimes its better just to have the door 
pre-made.

> Your small door is actually the screen door.

Lots of little holes?  Maybe.  But screen doors have their uses too.
Much better for the summertime to help make the livin' easy. ;-)

--bb



More information about the Digitalmars-d-announce mailing list