Alexander Klenin schrieb:

const
 IDECommandStrs: array[0..] of TIdentMapEntry = (

So what about semantics. The semantics here is that you don't need to define
the upper bound for a const array.

Althoug I agree with Juha that in general, it is a good idea to free programmer
from the burden of hand-counting const array elements, I have a few notes:

1) Proposed syntax seems somewhat suboptimal. Historically, Pascal
used redundancy and keywords to minimize the chance of errors and
make diagnostics easier. In that spirit, I think some active indication
of arbitrary upper bound is preferable to a mere omission:

IDECommandStrs: array[0..*] of TIdentMapEntry = (
IDECommandStrs: array[0..auto] of TIdentMapEntry = (
IDECommandStrs: array[0..end] of TIdentMapEntry = (

I also miss badly a feature to definitely tell the compiler about arrays, that currently are implemented as C-style compiler magic on pointers. A dynamic array under control of the user could be identified by e.g.:

  MyArray: array[] of TWhatSoEver;

Then the compiler could allow for MyArray[index], and reject error prone MyPointer[index] expressions. Such arrays can be initialized by const expressions (as is), or by New or GetMem by the user. As with the existing semantics, the array indices should be zero based.

2) We should think through and specify how multi-dimensional arrays should work:
matrix: [1..auto, 1..auto] of Integer = ((1, 2, 3), (4, 5, 6));

In such cases I would allow automatic dimensions *only* for the first dimension.

DoDi


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to