RFC on range design for D2

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Sep 8 21:03:22 PDT 2008


Jarrett Billingsley wrote:
> On Mon, Sep 8, 2008 at 8:24 PM, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>> Sergey Gromov wrote:
>>> Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
>>>> Walter, Bartosz and myself have been hard at work trying to find the
>>>> right abstraction for iteration. That abstraction would replace the infamous
>>>> opApply and would allow for external iteration, thus paving the way to
>>>> implementing real generic algorithms.
>>> opApply() wasn't my hero either. :)  Your article really looks like
>>> something I'd expect to find in D.  It only requires foreach support, and
>>> yeah, return by reference.
>> Indeed. Both are in the works.
> 
> Quick question about this one -- how will iterators get foreach
> support?  Are they classes or structs?  If they're structs, how will
> the compiler know something is an iterator?  Or will it be based on
> duck typing (if it looks like an iterator, it must be an iterator)?
> 
> And if this support involves "blessing" certain types within the
> runtime, what will this mean for other runtime libraries?

Great question. We'll go with structs and duck typing (why the heck 
don't they call it structural typing...) but we'll add interfaces for 
the range types so that they can be used dynamically too. Code 
generation will take care of gluing implementations into classes (more 
on that later).

As someone said in some thread on digitalmars.d, if you start with 
structs it's easy to move towards classes. The other way around is not 
as easy.


Andrei


More information about the Digitalmars-d-announce mailing list