[Lazarus] LNet und QT

Thomas Moritz thm_ml at thmoritz.de
Tue Jan 12 12:30:36 CET 2010


On Mon, Jan 11, 2010 at 02:40, Juha Manninen <juha.manninen at phnet.fi> wrote:
> Earlier in this thread you gave support for this new syntax:
>
> 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 = (

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));

> I copy the whole IDECommandStrs array below to demonstrate the problem.
[skip]
> const
>  IDECommandStrs: array[0..198] of TIdentMapEntry = (
>    // search
>    (Value: ecFind;                     Name: 'ecFind'),
>    (Value: ecFindAgain;                Name: 'ecFindAgain'),
[skip]

3) Finally, regardless of the preceeding discussion, that
IDECommandStrs array seems
like a tiresome and pointless exercise in code duplication. Why not use

function IDECommandStr(ec: TIdentMapEntry): String;
begin
  WriteStr(ec, Result);
end;

instead?




More information about the Lazarus mailing list