Should we remove int[$] before 2.067?
Nick Treleaven via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jan 30 08:53:24 PST 2015
On 30/01/2015 16:44, Kenji Hara via Digitalmars-d wrote:
> immutable[][$] a2 = [[1,2], [3,4]]; // a static array of mutable
> dynamic array of immutable ints
> static assert(is(typeof(a2) == immutable(int)[][2]));
...
> The type deduction will provide powerful way to type variables.
> Yes, ultimately they can be replaced with library function calls, but the
> call will be ugly and hard to understand. Consider making a2 by using
> library function. Can you show us a concept design for that?
auto a2 = staticArray!(immutable(int)[])([1,2], [3,4]);
This version of staticArray allows the user to (optionally) specify the
element type.
> And, staticArray function will not work for the following case:
>
> int function(int)[$] funcs = [
> a => a + 1,
> a => a * 2,
> ];
>
> The template lambdas have no type until they applied to the type `int
> function(int)`. So
auto funcs = staticArray!(int function(int))(
a => a + 1,
a => a * 2,
);
More information about the Digitalmars-d
mailing list