[Lazarus] const array syntax
Juha Manninen
juha.manninen at phnet.fi
Sun Jan 17 23:17:47 CET 2010
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:
> IDECommandList.FindIDECommand(ecFind).Name
I didn't create the array. It is in unit IDECommands and I just changed it
little for my patch. The mapping is used at least for macro recording.
"IDECommandList.FindIDECommand(ecFind).Name"
doesn't return the same name as this array stores. (or how?)
The array could be eliminated if Value were enum type instead of const.
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 there any fundamental problem against doing so?
It would be a logical refactoring because some editor commands are now used
globally (for designer) in my proposed patch, so they are in wrong place.
Juha Manninen
More information about the Lazarus
mailing list