Recommendations on avoiding range pipeline type hell

Jordan Wilson wilsonjord at gmail.com
Sun May 16 10:26:15 UTC 2021


On Sunday, 16 May 2021 at 09:55:31 UTC, Chris Piker wrote:
> On Sunday, 16 May 2021 at 09:17:47 UTC, Jordan Wilson wrote:
>
>> Another example:
>> ```d
>> auto r = [iota(1,10).map!(a => a.to!int),iota(1,10).map!(a => 
>> a.to!int)];
>> # compile error
>> ```
> Hi Jordan
>
> Nice succinct example.  Thanks for looking at the code :)
>
> So, honest question.  Does it strike you as odd that the exact 
> same range definition is considered to be two different types?
>
> Maybe that's eminently reasonable to those with deep knowledge, 
> but it seems crazy to a new D programmer.  It breaks a general 
> assumption about programming when copying and pasting a 
> definition yields two things that aren't the same type. (except 
> in rare cases like SQL where null != null.)
>
> On a side note, I appreciate that `.array` solves the problem, 
> but I'm writing pipelines that are supposed to work on 
> arbitrarily long data sets (> 1.4 TB is not uncommon).

There are those far more learned than me that could help explain. 
But in short, yes, it did take a little getting used to it - I 
would recommend looking at Voldemort types for D.

Ironically, use of Voldemort types and range-based programming is 
what helps me perform large data processing.

Jordan




More information about the Digitalmars-d-learn mailing list