Generalized Ranges

Pie? via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 5 15:22:36 PDT 2016


On Sunday, 5 June 2016 at 03:17:43 UTC, Joakim wrote:
> On Sunday, 5 June 2016 at 00:28:36 UTC, Pie? wrote:
>> [...]
>
> D can be made to do so, but I don't think ranges can, as they 
> assume linear traversal.
>
>> [...]
>
> For structures where a consistent linear traversal can be 
> specified, perhaps you can map it to D ranges, though that may 
> not always make sense for that structure.
>
>> [...]
>
> It is an interesting idea, basically generalizing D's linear 
> range operators to other non-linear structures.  It might be 
> worthwhile to define such basic traversal functions for common 
> structures like trees or certain kinds of graphs, so they have 
> a common interface.  I don't think using D ranges underneath 
> will work most of the time though.

I'll have to think about it more and next time I get a change to 
apply it I might try. Using lambdas makes working with arbitrary 
structures quite easy but there is probably a performance issue. 
With all the compile time logic D has, I imagine a lot of this 
could be optimized away.





More information about the Digitalmars-d mailing list