[fpc-pascal] Name of a var

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Mon Nov 21 14:22:16 CET 2011



On Mon, 21 Nov 2011, Rainer Stratmann wrote:

> Am Monday 21 November 2011 14:08:43 schrieb michael.vancanneyt at wisa.be:
>> On Mon, 21 Nov 2011, Rainer Stratmann wrote:
>>> Is it possible to get information of the name of a var?
>>>
>>> For Example.
>>>
>>> var
>>> counter : longint;
>>> varname : shortstring;
>>>
>>> varname := nameofvar( counter );
>>>
>>> The content of varname then is 'counter'.
>>
>> There is no way in Pascal.
> I think all the necessary information for this function are available.
> The compiler knows the names of all vars. So why shouldn't it be possible to
> put the name in a shortstring?

If we choose to implement such a function, yes. 
My response was based on the compiler as it is.

>> Conceivably, you can make such a function that
>> returns the name when debug info is included in the binary.
> Or put only the specific information when the compiler detects this function
> to avoid saving all vars.

Obviously.

Michael.



More information about the fpc-pascal mailing list