auto arr = [1, 2, 3] should be a static array, not a GC allocated array
H. S. Teoh
hsteoh at qfbox.info
Thu Jul 14 19:39:17 UTC 2022
On Thu, Jul 14, 2022 at 12:18:34PM -0700, Ali Çehreli via Digitalmars-d wrote:
> On 7/14/22 11:55, H. S. Teoh wrote:
>
> > Maybe int[static array] would make it much more obvious to newbies. ;-)
>
> Looks good but 'array' is a legal identifier. :( Luckily nothing some
> creative acrostic can't fix:
>
> int[static alias,ref,return,assert,'y'] arr;
[...]
> Ok, too much silliness for one day. I stop here.
[...]
But but but... this is proposed syntax for automatically detecting the
length of a static array. At the very least, it should spell out this
fact:
int[auto static pragma(array, length)] arr;
The pragma, of course, is to provide a context where legal identifiers
have special meaning. :-D
On a serious note, though, int[$] is ideal.
T
--
Music critic: "That's an imitation fugue!"
More information about the Digitalmars-d
mailing list