N-dimensional slices is ready for comments!

jmh530 via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Sun Jun 21 09:04:03 PDT 2015


On Friday, 19 June 2015 at 10:13:42 UTC, Ilya Yaroshenko wrote:
>
> You can slice fixed size arrays:
>
>
> auto myFun()
> {
>      float[4096] data;
>      auto tensor = data[].sliced(256, 16);
>      ///use tensor
> }
>

After playing around with some stuff more, I keep finding the 
syntax for the static and dynamic arrays confusing (more general 
to D than your code). It just seems weird that you have to treat 
them differently when applying a function to them.

Also, whenever you have an expanlation point followed by a type 
that could be an array, you need to make sure to put parentheses 
around it. For instance,

to!(real[])(x);
instead of
to!real[](x);

or

auto fp = &function!(real[]);

instead of
auto fp = &function!real[];

I wish the documentation made it a bit more clear that you have 
to do this.


More information about the Digitalmars-d-announce mailing list