static array with inferred size

Steven Schveighoffer schveiguy at yahoo.com
Wed Sep 20 03:12:59 UTC 2017


On 9/19/17 10:46 PM, Meta wrote:
> With all due respect to Andrei, I think he overreacted a bit and it was 
> a mistake to revert static array length deduction (although the array/aa 
> type deduction on steroids was probably overly complicated so that was a 
> good call). Maybe now that @nogc and betterC are squarely in focus we 
> can revisit array length deduction.

The length deduction is so obviously needed, especially when you want to 
avoid heap allocations.

char["hello".length] = "hello";

It's just so terrible. I can't figure out a good way around it.

Deducing types is probably reasonable as a request, but I don't see how 
one requires the other. There is no need to repeat the entire literal to 
form the type, and you aren't specifying the type anyway. At most you 
have to enter the type one more time (in the case of explictly typing an 
element).

But having to manually count all the elements in an array literal? That 
is torture! D should be better than that.

-Steve


More information about the Digitalmars-d mailing list