Fixing C's Biggest Mistake

IGotD- nise at nise.com
Thu Jan 5 19:10:47 UTC 2023


On Thursday, 5 January 2023 at 18:19:12 UTC, Max Samukha wrote:
> On Thursday, 5 January 2023 at 17:30:59 UTC, H. S. Teoh wrote:
>
>> 	int[$] staticArray;	// "but $ looks ugly!"
>
> We need to stop listening to people who hate dollars. 
> Seriously, $ is already in the language and means "length of 
> the array". Let's use it.

I didn't like the dollars in the DIP with the enum inference 
(https://forum.dlang.org/thread/wpqmuysuxadcwnzypnxk@forum.dlang.org). However, here it makes sense and already mean something (arrays length).

uint[$] y = [1,2,3];

Looks ok to me. I would support a DIP suggesting this.

uint[..] y = [1,2,3];

is also ok. Static array length based on initializer is long 
overdue.


More information about the Digitalmars-d mailing list