[fpc-pascal] Name of a var

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Tue Nov 22 12:14:54 CET 2011



On Tue, 22 Nov 2011, Rainer Stratmann wrote:

> Am Tuesday 22 November 2011 12:05:07 schrieb michael.vancanneyt at wisa.be:
>> On Tue, 22 Nov 2011, Sven Barth wrote:
>>> 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).
>>
>> I beg you.... That's the most weak argument I've ever heard.
>>
>> The name of a variable is only used for debugging, and then you can just
>> as well use the debug info. And the change of a name is usually done with
>> search&replace, option whole word, so the text 'counter' should get changed
>> as well.
>>
>> The name of a variable is of absolutely no use to the end user.
> No that's not correct.
> That is in my eyes an excuse not to deal with it.

That depends entirely on the cost of this function. For example the use
Graeme wants is not possible without adding a complete run-time environment
a la .NET.

> The search&replace function in lazarus is not the best.
> I often change the name in the declaration and then see what the compiler
> says. The compiler does not complain with the text 'counter'. So then you may
> feel 'secure' but it is not.

Once more: the name in the debug message is totally irrelevant. I would fire
anyone RELYING on that. And since that's all you want the function for, I
consider the use totally marginal...

Michael.



More information about the fpc-pascal mailing list