const arr: array[] of integer = (1, 2, 3, 4, 5);
//length would be infered to be 5, with low 0, high 4
This one would be truly useful. I remember suggesting it at 2009 or 2010 but it was rejected immediately.
I have a related feature request still open for Codetools :
http://bugs.freepascal.org/view.php?id=15548I feel absolutely dummy when I have to count the elements. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ..., 55, 56, 57.
I remember the compiler then says something like :
"There are 59 elements, not 57. Why did you give me a wrong number? Shame on you!"
So, if the compiler is clever enough to count the elements, why can't it use that count?
Why me, a stupid human being, must count them for it?
I understand the original array syntax request will be rejected because it only saves you typing 3 characters "0.." which is not very relevant.
This const array syntax however would be a big improvement. Even Marcov cannot deny it.