Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-11

Name of a var

31 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Rainer Stratmann

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'.

Reply by email

Rainer Stratmann
to Unknown author: There is no way in Pascal. Conceivably, you can make such a function that returns the…

Am Monday 21 November 2011 14:08:43 schrieb

Show quoted text 14 lines
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?

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.

Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Unknown author
to Rainer Stratmann: Is it possible to get information of the name of a var? For Example. var counter :…
Rainer Stratmann wrote 11 lines
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. Conceivably, you can make such a function that returns the name when debug info is included in the binary.

Michael.

Reply by email

Unknown author
to Rainer Stratmann: Am Monday 21 November 2011 14:08:43 schrieb I think all the necessary information for…
Rainer Stratmann wrote 18 lines
Am Monday 21 November 2011 14:08:43 schrieb > 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.

Reply by email

Rainer Stratmann
to Jeppe Græsdal Johansen
Jeppe Græsdal Johansen wrote 14 lines
Den 21-11-2011 13:56, Rainer Stratmann skrev: > 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'. It would most likely be very easy to implement, but what is the need?

I am storing vars in a textfile like:

mintemp: 300
maxtemp: 350

And so on ...

I put the pointer to the var and the savetext (the same name as the var) in an array wich describes all the vars. When saving all vartexts are written and then the values.
It would be easier then to detect double names for example. The compiler does it then.

Reply by email

Martin
to Rainer Stratmann
Rainer Stratmann wrote 15 lines
Am Monday 21 November 2011 20:06:10 schrieb Jeppe Græsdal Johansen: > It would most likely be very easy to implement, but what is the need? I am storing vars in a textfile like: mintemp: 300 maxtemp: 350 And so on ... I put the pointer to the var and the savetext (the same name as the var) in an array wich describes all the vars. When saving all vartexts are written and then the values. It would be easier then to detect double names for example. The compiler does it then.

If you make all the variables published properties of a class, then you can use RTTI

Reply by email

Sven Barth
to Unknown author: If we choose to implement such a function, yes. My response was based on the compiler as…

Am 21.11.2011 14:22, schrieb

Show quoted text 26 lines
On Mon, 21 Nov 2011, Rainer Stratmann wrote: > Am Monday 21 November 2011 14:08:43 schrieb >> 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.

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.)

Regards,
Sven

Reply by email

Unknown author
to Sven Barth
Sven Barth wrote 31 lines
Am 21.11.2011 14:22, schrieb > > > On Mon, 21 Nov 2011, Rainer Stratmann wrote: > >> Am Monday 21 November 2011 14:08:43 schrieb >>> 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. 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 ?

Michael.

Reply by email

Sven Barth
to Unknown author

Am 22.11.2011 10:13, schrieb

Show quoted text 18 lines
>> 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

Reply by email

Graeme Geldenhuys
to Unknown author: But what is the use ? As far as I can see, it forces you to type more. Typing…
Show quoted text 10 lines
Typing VarName:=nameofvar( counter ); is more work than VarName:='counter'; So what's the point ?

Maybe there is a use for it in the dbugintf unit?

eg:

SendInteger(counter)

result on the debug server would then possibly be something like...

2011-11-22 Debug: counter = 20

The SendInteger() function will do the identifier-to-string call, not the developer. But then, the parameter name might be used, and not the original identifier name - not sure.

Anyway, currently you have to do the following in dbugintf...

   SendInteger('counter', counter);

I find this annoying, but with CodeTools+SyncroEdit I have managed to reduce my type too. :-)

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Sven Barth
to Graeme Geldenhuys
Graeme Geldenhuys wrote 15 lines
> So what's the point ? Maybe there is a use for it in the dbugintf unit? eg: SendInteger(counter) result on the debug server would then possibly be something like... 2011-11-22 Debug: counter = 20 The SendInteger() function will do the identifier-to-string call, not the developer. But then, the parameter name might be used, and not the original identifier name - not sure.

It would use the name of the formal parameter, as this would mean that the compiler would need to pass the name of the variable as well (without knowing whether this will be needed at all).

Anyway, currently you have to do the following in dbugintf... SendInteger('counter', counter);

It would more be something like

SendInteger(StrOfIdent(counter), counter);

So now reduction of typing here, but a check by the compiler if you choose to rename "counter".

Regards,
Sven

Reply by email

Rainer Stratmann
to Unknown author: But what is the use ? As far as I can see, it forces you to type more. Typing…

Am Tuesday 22 November 2011 10:13:20 schrieb

Show quoted text 42 lines
On Tue, 22 Nov 2011, Sven Barth wrote: > Am 21.11.2011 14:22, schrieb >> On Mon, 21 Nov 2011, Rainer Stratmann wrote: >>> Am Monday 21 November 2011 14:08:43 schrieb >>>> 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. > > 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 ?

Compiler check of the name as Sven also mentioned. This check is very important.

Michael.

Reply by email

Rainer Stratmann
to Unknown author: I beg you.... That's the most weak argument I've ever heard. The name of a variable is…

Am Tuesday 22 November 2011 12:05:07 schrieb

Show quoted text 36 lines
On Tue, 22 Nov 2011, Sven Barth wrote: > Am 22.11.2011 10:13, schrieb >>>> 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.
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.

Michael.

Reply by email

Unknown author
to Graeme Geldenhuys: Maybe there is a use for it in the dbugintf unit? eg: SendInteger(counter) result on the…
Graeme Geldenhuys wrote 17 lines
On 2011-11-22 11:13, wrote: > > Typing > > VarName:=nameofvar( counter ); > > is more work than > > VarName:='counter'; > > So what's the point ? Maybe there is a use for it in the dbugintf unit? eg: SendInteger(counter)

No, if I was to program it using varname, I would get the name of the parameter in the function SendInteger.

You need the address of the variable that was passed to SendInteger. Obviously, there is no way the compiler can know that.

Michael.

Reply by email

Unknown author
to Sven Barth: Am 22.11.2011 10:13, schrieb The best argument for such a feature is that the name is…
Sven Barth wrote 26 lines
Am 22.11.2011 10:13, schrieb >>> 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.

Michael.

Reply by email

Rainer Stratmann
to Unknown author: That depends entirely on the cost of this function. For example the use Graeme wants is…

Am Tuesday 22 November 2011 12:14:54 schrieb

Show quoted text 53 lines
On Tue, 22 Nov 2011, Rainer Stratmann wrote: > Am Tuesday 22 November 2011 12:05:07 schrieb >> On Tue, 22 Nov 2011, Sven Barth wrote: >>> Am 22.11.2011 10:13, schrieb >>>>>> 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.

Are you sure that you are objective in this diskussion?

Show quoted text 7 lines
And since that's all you want the function for, I consider the use totally marginal... Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Unknown author
to Rainer Stratmann: Am Tuesday 22 November 2011 10:13:20 schrieb Compiler check of the name as Sven also…
Rainer Stratmann wrote 45 lines
Am Tuesday 22 November 2011 10:13:20 schrieb > On Tue, 22 Nov 2011, Sven Barth wrote: >> Am 21.11.2011 14:22, schrieb >>> On Mon, 21 Nov 2011, Rainer Stratmann wrote: >>>> Am Monday 21 November 2011 14:08:43 schrieb >>>>> 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. >> >> 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 ? Compiler check of the name as Sven also mentioned. This check is very important.

And as I answered, I can't possibly imagine why this would matter in the least.

Michael.

Reply by email

Unknown author
to Rainer Stratmann: Am Tuesday 22 November 2011 12:05:07 schrieb No that's not correct. That is in my eyes an…
Rainer Stratmann wrote 39 lines
Am Tuesday 22 November 2011 12:05:07 schrieb > On Tue, 22 Nov 2011, Sven Barth wrote: >> Am 22.11.2011 10:13, schrieb >>>>> 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.

Reply by email

Graeme Geldenhuys
to Unknown author: No, if I was to program it using varname, I would get the name of the parameter in the…
No, if I was to program it using varname, I would get the name of the parameter in the function SendInteger.

That's what I thought - and mentioned that fact.

You need the address of the variable that was passed to SendInteger. Obviously, there is no way the compiler can know that.

In that case I have no more use cases for the "name of var" feature. :)

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Marco van de Voort
to Sven Barth: Am 22.11.2011 10:13, schrieb The best argument for such a feature is that the name is…

In our previous episode, Sven Barth said:

Show quoted text 13 lines
> 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).

The first or the second invocation of sendinteger ? :-)

sendinteger(nameofvar(var1),var2);

is an easily made mistake (copy and paste like).

So I have some doubts about this argument.

Reply by email

John Lee
to Marco van de Voort

Call me old fashioned, but to ask for this capability to save typing seems bizarre.

I'l like it, if as has been suggested it is easy to do, so that it is easier & more error free to implement a variable save and restore capability. I have a program in which some variables values need to be stored in a file, and restored on restart. I do this by by storing a text representation followed by the variable eg jim123:0000. This is then restored by getting the file & finding string jim23: & assigning the value after it to jim23 etc etc. It's not easy to do this for say 40 disparately named variables because the saves and restores have to be individually coded - with this capability it could be done, reliably, in a loop.

John

Reply by email

Unknown author
to Rainer Stratmann: Am Tuesday 22 November 2011 12:14:54 schrieb Are you sure that you are objective in this…
Rainer Stratmann wrote 22 lines
>>> 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. Are you sure that you are objective in this diskussion?

As much as anyone else in this discussion ? :-)

I just know daily practice; how I and my collegae debug apps. I can't for the life of me imagine why you would *rely* on such a feature.

IMHO it adds only very marginal value: in the the case when you rename a variable, possibly a debug message will not reflect the name change. How marginal is that ?

Doubly so, because in case the executable contains debug info, you can write the function yourself so it looks up the name in the debug info.

But hey, if someone wants to implement this, why not. There are other things in FPC of which I personally do not see the added value...

Michael.

Reply by email

Rainer Stratmann
to Unknown author

Am Tuesday 22 November 2011 14:09:42 schrieb

Show quoted text 39 lines
On Tue, 22 Nov 2011, Rainer Stratmann wrote: >>>> 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. > > Are you sure that you are objective in this diskussion? As much as anyone else in this discussion ? :-) I just know daily practice; how I and my collegae debug apps. I can't for the life of me imagine why you would *rely* on such a feature. IMHO it adds only very marginal value: in the the case when you rename a variable, possibly a debug message will not reflect the name change. How marginal is that ? Doubly so, because in case the executable contains debug info, you can write the function yourself so it looks up the name in the debug info. But hey, if someone wants to implement this, why not. There are other things in FPC of which I personally do not see the added value...

It is not that I rely on such a feature. But - of course - when implemented I would use it and it would be strange if this function then disappears.

Now I register every storable value in a list.
// pointer to val, name, alternative name when reading a file, initial value,
min value, max value
myregistervar( @counter , 'counter' , 'counteralt' , 10 , 5 , 200 );
myregistervar( @... , '...' , ... , ... , ... );

counteralt is the alternative name in case of changing the name of the variable. In this case reading from the file does not get lost. But when storing again in the file the new name is used. Ideally the name does not change, but if you have a huge list that's also for the reason of simplicity better to change the names sometimes.

I don't need all the debug info.

Michael.

Reply by email

Martin
to Unknown author: As much as anyone else in this discussion ? :-) I just know daily practice; how I and my…
Show quoted text 6 lines
On Tue, 22 Nov 2011, Rainer Stratmann wrote: >> >> Once more: the name in the debug message is totally irrelevant.

afaik debugging was not the initially mentioned purpose. Streaming to a file was. That already exists, see last line.

>> I would fire anyone RELYING on that. > Are you sure that you are objective in this diskussion? As much as anyone else in this discussion ? :-)

Just NameOfVar(x) is indeed not very useful.

But there where hints what people would also want.
- The Name of a variable a pointer is pointing to (or that was given by the callee for a param)
- looping through a list of variables

That would require a list of all variables and there names. So the implementation cost of the feature would be a lot higher.

And as I already wrote, why re-invent the wheel? Use published properties of an object, instead of variables. They have RTTI, so they can already do all of this.

Reply by email

Martin
to Rainer Stratmann: There are many functions I don't need. For example am I not a friend of dynamic allocated…
Rainer Stratmann wrote 9 lines
Am Tuesday 22 November 2011 13:50:06 schrieb John Lee: > Call me old fashioned, but to ask for this capability to save typing seems > bizarre. There are many functions I don't need. For example am I not a friend of dynamic allocated memory. I have reasons for not using it. You may have reasons for using it heavily. Why shouldn't there exist a function you don't need or see the need for?

I don't think the question is that simple.

Yes, there are many features not everybody needs. Yet they have to be chosen by some means (language design) and yet there will always be disagreement.

But remember each feature has a cost. Not only what it adds to your app (which it may well be worth), but also what it adds to the compiler: Now and in future maintenance.

And are you sure this feature is really that simple? Now and in all future?

Now it may just be an: check (for existence as var) and quote the literal identifier. But soon you or someone wants to pass a pointer to a variable, and that will raise the cost a lot.

Reply by email

John Lee
to Martin: I don't think the question is that simple. Yes, there are many features not everybody…
Show quoted text 7 lines
> Yes, there are many features not everybody needs. Yet they have to be chosen by some means (language design) and yet there will always be disagreement. No, do the minimum
But remember each feature has a cost. Not only what it adds to your app (which it may well be worth), but also what it adds to the compiler: Now and in future maintenance.
Show quoted text 7 lines
And are you sure this feature is really that simple? Now and in all future? Now it may just be an: check (for existence as var) and quote the literal identifier. But soon you or someone wants to pass a pointer to a variable, and that will raise the cost a lot. KISS principle - at present it just cannot be done w/o messing with debug,

so just check, & quote the literal val as you suggestl Minimal compiler cost?

Reply by email

Sven Barth
to Marco van de Voort: In our previous episode, Sven Barth said: The first or the second invocation of…
Marco van de Voort wrote 20 lines
In our previous episode, Sven Barth said: >> 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). The first or the second invocation of sendinteger ? :-) sendinteger(nameofvar(var1),var2); is an easily made mistake (copy and paste like).

I'm a huge fan of synchron edit in Lazarus :P

So I have some doubts about this argument.

The Pros are very few, I admit. Another reason (the other mailed as an answer to one of Martin's mails) why this is a low priority feature for me and I'll implement other "gems" first ;)

Regards,
Sven

Reply by email