Inferring static array size

NotYouAgain NotYouAgain at gmail.com
Fri May 3 11:45:27 UTC 2024


On Friday, 3 May 2024 at 10:04:57 UTC, Nick Treleaven wrote:
> On Friday, 3 May 2024 at 09:15:02 UTC, rkompass wrote:
>> I read through the discusion there and found it quite 
>> digressing and not productive.
>> There was no real weighing the pros against the cons.
>>
>> Of course we have staticArray, but in programming it's much 
>> about conciseness which at the same time allows for 
>> effortlessy (intuitively) transporting the meaning of a 
>> construct.
>> And this criterion here is fulfilled.
>> No new symbol is introduced, just a meaning extended, which is 
>> immediatly clear.
>>
>> Could DIP 1039 be restarted?
>
> I think the sticking point is making an implementation that 
> does not complicate the compiler code much.

Yes, i was thinking to post the exact same comment actually ;-)

As it is, CTFE using .staticArray is a useful alternative... 
unless you're trying to do something like this:

module m;
@safe:
private:

import std;

private enum numItems = 10;

class myClass {}

void main()
{
     // Object[numItems] objectArr = generate!(() => new 
myClass())().take(numItems).array;

     import std.array : staticArray;
     auto arr = generate!(() => new 
myClass())().take(numItems).staticArray; // nope
}



More information about the dip.ideas mailing list