array operations and ranges

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 30 22:10:44 PDT 2015


On 4/26/2015 3:17 AM, Manu via Digitalmars-d wrote:
> Array operations are super cool, and I'm using ranges (which kinda
> look and feel like arrays) more and more these days, but I can't help
> but feel like their incompatibility with the standard array operations
> is a massive loss.
>
> Let's say I want to assign one range to another: b[] = a[];
> It's not clear to me why this should fall down if I want to apply a
> lazy operation for instance: b[] = a.map!(e=>e*2)[];
> ... or something to that effect.
>
> I find that my lazy ranges often end up on the stack, but I can't
> assign/initialise directly: float[] a = b.transform[];
> Instead I need to: float[] a;  b.transform.copy(a[]);
>
> The fact that they don't mix with array expressions or operators means
> as soon as a lazy range finds it wants to enter existing array code,
> it needs to be converted to a series of map()'s.
>
> There must be years of thoughts and work on this sort of thing?
> It seems arrays and ranges are unnecessarily distanced from
> eachother... what are the reasons for this?

I think you've got the start of some dazz ideas. I want to think about this more.


More information about the Digitalmars-d mailing list