auto arr = [1, 2, 3] should be a static array, not a GC allocated array

Ali Çehreli acehreli at yahoo.com
Thu Jul 14 17:57:13 UTC 2022


On 7/14/22 09:50, jfondren wrote:

 > inferred length with a feature like `int[_] arr`.

Is there a reason why that can't be added to D? I don't see any downside.[1]

Ali

[1] Other than bike-shedding:

- int[$]      // Not perfect because the array does not have a length
               // (yet) but $ means exactly that in other contexts.

- int[auto]   // Better but 'auto' means "type" to me.

- int[static] // Aaaah... good old 'static' to the rescue. :D

- int[{}]     // Meaning "take the length from the initializer".
               // (Yes, I am joking.)

- int[=]      // Because this is initialization after all.

- int[+]      // Meaning: "Please count for me."

- int[∑1]     // Ditto but because not all keyboards have that
               // character, the alternative tetragraph is proposed
               // below.

- int[???<1]  // Readable enough? :o)



More information about the Digitalmars-d mailing list