Static Length Propagation of Ranges
Meta via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Oct 20 09:25:53 PDT 2016
On Thursday, 20 October 2016 at 13:05:05 UTC, Nordlöw wrote:
> On Thursday, 20 October 2016 at 12:38:40 UTC, Nordlöw wrote:
>> ElementType!R[n] arrayN(size_t n, R)(R r)
>> {
>> assert(r.length == n);
>> typeof(return) dst;
>> import std.algorithm.mutation : copy;
>> r.copy(dst[]);
>> return dst;
>> }
>
> Is there a place for part of this logic in Phobos?
>
> I'm thinking perhaps array{N,Exactly} should be added to
> std.array.
>
> The idea came to me after learning about dependent types in
> Idris:
>
> http://www.idris-lang.org/
There was a pull request awhile back for a small function that
creates fixed-length arrays, but I think it was only intended to
create them from dynamic arrays (such as `auto sarr = [1, 2,
3].staticArray`). Personally I think it would be nice to have a
version of `array` that creates a static array, but I don't know
how often it would be used or what the pitfalls are, if any.
More information about the Digitalmars-d-learn
mailing list