Re: [Lazarus] const array syntax

2010-01-24 Thread Martin
On 18/01/2010 06:29, Vincent Snijders wrote: Juha Manninen schreef: I was already thinking of moving all constants in SynEditKeyCmds and IDECommands to one unit and changing them to enum type, and then getting rid of this array and the similar EditorCommandStrs array. "WriteStr" is able to re

Re: [Lazarus] const array syntax

2010-01-17 Thread Vincent Snijders
Juha Manninen schreef: I was already thinking of moving all constants in SynEditKeyCmds and IDECommands to one unit and changing them to enum type, and then getting rid of this array and the similar EditorCommandStrs array. "WriteStr" is able to return the string representation of an enum. Is

Re: [Lazarus] const array syntax

2010-01-17 Thread Juha Manninen
Hi! >> IDECommandStrs: array[0..198] of TIdentMapEntry = ( >> // search >> (Value: ecFind; Name: 'ecFind'), >> (Value: ecFindAgain;Name: 'ecFindAgain'), >>... > > Why create a fixed array for this? > These items are registered, so you can do: > ID

Re: [Lazarus] const array syntax

2010-01-17 Thread Mattias Gaertner
On Sun, 10 Jan 2010 18:40:49 +0200 Juha Manninen wrote: >[...] > IDECommandStrs: array[0..198] of TIdentMapEntry = ( > // search > (Value: ecFind; Name: 'ecFind'), > (Value: ecFindAgain;Name: 'ecFindAgain'), >... Why create a fixed array for this

Re: [Lazarus] const array syntax

2010-01-13 Thread Jürgen Hestermann
On the zero-lower-bond question: I personally have become totally used to 0 as a lower bound on arrays and use them all the time. That reminds me of another problem: The index type may not only be an integer, it can also be an enumeration type: type MyEnumeration = (Home,Office,Iland,Remote)

Re: [Lazarus] const array syntax

2010-01-13 Thread Doug Chamberlin
John wrote: array(0..Some_constant key_word_or_directive ) of Option 1: Reads much better as MyArray: calculated array of TMyType = (value1, value2, ..); Option 2: Having the IDE check the length of the array by counting the values and adjusting the upper bounds constant is a perfect

Re: [Lazarus] const array syntax

2010-01-13 Thread John
Doug Chamberlin wrote: Duncan Parsons wrote: Must confess, I feel "arr:[0..end] of " makes more sense to me than use of "var" or "..]" The latter suggests something forgotten or a typo. I agree that just leaving out the ending limit is against the spirit of Pascal. +1 I can live with the s

Re: [Lazarus] const array syntax

2010-01-13 Thread Hans-Peter Diettrich
Doug Chamberlin schrieb: Must confess, I feel "arr:[0..end] of " makes more sense to me than use of "var" or "..]" The latter suggests something forgotten or a typo. I agree that just leaving out the ending limit is against the spirit of Pascal. I can live with the syntax of MyArray:[0..var

Re: [Lazarus] const array syntax

2010-01-13 Thread Doug Chamberlin
Duncan Parsons wrote: Must confess, I feel "arr:[0..end] of " makes more sense to me than use of "var" or "..]" The latter suggests something forgotten or a typo. I agree that just leaving out the ending limit is against the spirit of Pascal. I can live with the syntax of MyArray:[0..var] o

Re: [Lazarus] const array syntax

2010-01-13 Thread Duncan Parsons
ilto:kle...@gmail.com] Sent: 12 January 2010 14:22 To: Lazarus mailing list Subject: Re: [Lazarus] const array syntax On Tue, Jan 12, 2010 at 23:59, Paul Ishenin wrote: > Jürgen Hestermann wrote: >> >> That's an issue, yes. Although, in this case the constant "auto"

Re: [Lazarus] const array syntax

2010-01-12 Thread Jürgen Hestermann
Paul Ishenin schrieb: That's an issue, yes. Although, in this case the constant "auto" could be independend from the keyword "auto". So it would not fail. Instead constant and array size would not be related in any way (although it appears like that). I can't. How compiler will decide whethe

Re: [Lazarus] const array syntax

2010-01-12 Thread Hans-Peter Diettrich
Jürgen Hestermann schrieb: IDECommandStrs: array[0..*] of TIdentMapEntry = ( IDECommandStrs: array[0..auto] of TIdentMapEntry = ( IDECommandStrs: array[0..end] of TIdentMapEntry = ( I would vote for "auto". But beside finding a good syntax I am not sure whether it is so easy to implement such

Re: [Lazarus] const array syntax

2010-01-12 Thread Alexander Klenin
On Tue, Jan 12, 2010 at 23:59, Paul Ishenin wrote: > Jürgen Hestermann wrote: >> >> That's an issue, yes. Although, in this case the constant "auto" could be >> independend from the keyword "auto". So it would not fail. Instead constant >> and array size would not be related in any way (although i

Re: [Lazarus] const array syntax

2010-01-12 Thread Paul Ishenin
Jürgen Hestermann wrote: That's an issue, yes. Although, in this case the constant "auto" could be independend from the keyword "auto". So it would not fail. Instead constant and array size would not be related in any way (although it appears like that). I can't. How compiler will decide whethe

Re: [Lazarus] const array syntax

2010-01-12 Thread Jürgen Hestermann
IDECommandStrs: array[0..*] of TIdentMapEntry = ( IDECommandStrs: array[0..auto] of TIdentMapEntry = ( IDECommandStrs: array[0..end] of TIdentMapEntry = ( I would vote for "auto". I wont, since the following would fail: const auto = 10; arr: [1..auto] of Integer = (1, 2, 3); That's an issu

Re: [Lazarus] const array syntax

2010-01-12 Thread Juha Manninen
On tiistai, 12. tammikuuta 2010 00:30:09 Alexander Klenin wrote: > 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 bo

Re: [Lazarus] const array syntax

2010-01-12 Thread Marc Weustink
Alexander Klenin schrieb: 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: IDEComma

Re: [Lazarus] const array syntax

2010-01-12 Thread Jürgen Hestermann
Alexander Klenin schrieb: 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: IDECo

Re: [Lazarus] const array syntax

2010-01-11 Thread Hans-Peter Diettrich
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

Re: [Lazarus] const array syntax

2010-01-11 Thread dmitry boyarintsev
On Tue, Jan 12, 2010 at 1:30 AM, Alexander Klenin wrote: > > 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 i

Re: [Lazarus] const array syntax

2010-01-11 Thread Paul Ishenin
Alexander Klenin wrote: 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? Maybe it was n

Re: [Lazarus] const array syntax

2010-01-11 Thread Alexander Klenin
On Mon, Jan 11, 2010 at 02:40, Juha Manninen 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. Al

[Lazarus] const array syntax

2010-01-10 Thread Juha Manninen
On sunnuntai, 10. tammikuuta 2010 15:53:34 Hans-Peter Diettrich wrote: > dmitry boyarintsev schrieb: > >> At least the error message could mention the actual number of entries, > >> as found in source code. This doesn't require any change to the language > >> or compiler, only an change to the erro