Inferring static array size

rkompass rkompass at gmx.de
Fri May 3 12:49:33 UTC 2024


On Friday, 3 May 2024 at 12:12:29 UTC, NotYouAgain wrote:
> On Friday, 3 May 2024 at 11:45:27 UTC, NotYouAgain wrote:
>> ...
>
> and this won't work either:
>
> int i = 2;
> //int[10] powersOfTwo = generate!(() => i *= 
> 2)().take(10).array; // fine
> auto powersOfTwo = staticArray!(generate!(() => i *= 
> 2)().take(10).array); // nope

This can be seen as a flaw of staticArray.?.

 From my perspective it's more about having the ability to create 
self-evident code:

```
int[]     integers = [0..20];
int[$]  staticInts = [0..20];
int[]        evens = [0,2,..,20];
int[$] staticEvens = [0,2,..,20];
```
or something similarly obvious would be on my wishlist.
Of course this would not allow for powers of two, which is yet a 
step more involved.



More information about the dip.ideas mailing list