[Lazarus] const array syntax

Martin lazarus at mfriebe.de
Sun Jan 24 15:40:31 CET 2010


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 return the string representation of an enum.
>> Is there any fundamental problem against doing so?
>
> Just keep in mind that the string is used in saving the editor 
> preferences and must be kept stable, so old configs can be read. If 
> you rename the constant, you can decide in the current situation to 
> keep the string the same, but if it is an enum, you cannot.
Not sure if it applies in this case, but for any case in which it applies:

If the string is only required for saving options/xml files, then it 
should be defined in the editor options unit (maybe?). But IMHO in this 
case you can go with the enum to start with. If the enum is changed at 
any point in the future, the option-loader can have a translation table 
for old entries.

Martin




More information about the Lazarus mailing list