[fpc-pascal] Name of a var

Sven Barth pascaldragon at googlemail.com
Tue Nov 22 10:44:01 CET 2011


Am 22.11.2011 10:13, schrieb michael.vancanneyt at wisa.be:
>>> If we choose to implement such a function, yes. My response was based on
>>> the compiler as it is.
>>
>> Seems like I'm not the only one that likes to have such a function.
>> Though I would extend it to convert identifiers in scope to strings
>> (such as functions names etc.)
>
> But what is the use ? As far as I can see, it forces you to type more.
>
> Typing
>
> VarName:=nameofvar( counter );
>
> is more work than
>
> VarName:='counter';
>
> So what's the point ?

The best argument for such a feature is that the name is checked by the 
compiler. If I change the declaration of the variable the compiler will 
complain in the first case, but not in the second (let's assume that we 
don't need to care about some kind of backwards compatibilty, just 
because we wrote the identifiers to a file in different versions of the 
application were the variable had different names).

Regards,
Sven



More information about the fpc-pascal mailing list