Dereference opereator in interpolation
Dereference opereator in interpolation
The dereference operator defines a restriction not to be used in interpolation, i.e. in heredoc and in double quotes.
Is there a good reason for this?
As it means that every time you need a deref. variable in heredoc or quotes, you must first copy it to a temp- (or dummy-)var, and refer to that in the text. I'd think the combi of deref and a var, i.e. *$xxx, is rather unique and should not be the reason.
So, if possible, I wish to allow dereferenced vars in interpolation.
Is there a good reason for this?
As it means that every time you need a deref. variable in heredoc or quotes, you must first copy it to a temp- (or dummy-)var, and refer to that in the text. I'd think the combi of deref and a var, i.e. *$xxx, is rather unique and should not be the reason.
So, if possible, I wish to allow dereferenced vars in interpolation.
Win11 Pro 23H2 Gerrman
-
- Site Admin
- Posts: 63451
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Dereference opereator in interpolation
Indeed, I see no good reason not to allow dereferencing in interpolation, and curiously (though I comment and document everything I do) I can find no explanation for why I stopped allowing it in v14.30.0006 - 2014-07-14 14:30.
So, experimentally, I will allow it.
So, experimentally, I will allow it.
FAQ | XY News RSS | XY Bluesky
Re: Dereference opereator in interpolation
To be true - I didn't really expect it. But if you don't ask...
OK: I'll be the first to test it
(Just to say: I'm the user using <<<#>>> for heredoc)
Thanks!
OK: I'll be the first to test it

(Just to say: I'm the user using <<<#>>> for heredoc)
Thanks!
Win11 Pro 23H2 Gerrman
-
- Site Admin
- Posts: 63451
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Dereference opereator in interpolation
I made it like this now ...
... but I guess this is not really expected. I'd like to hear what you think.
Code: Select all
Note that the dereferencing is performed recursively until the task is completely done:
// It's a fish! (*$vd2 -> *$vd -> $v -> "fish")
$v = "fish"; $vd = '$v'; $vd2 = '*$vd'; echo "It's a *$vd2!"; //fish (*$vd2 -> *$vd -> $v -> "fish")
FAQ | XY News RSS | XY Bluesky
Re: Dereference opereator in interpolation
OK: a bit strange as for one '*' there can be several substitutions.
There *can* be situations where it is negative - but I think more are positive.
And I can think of no situation where I have a dereferenced variable containing another var name, i.e. where it would happen unexpected.
So I would say it's OK to be recursive.
(As I know me I would use it somewhen
)
There *can* be situations where it is negative - but I think more are positive.
And I can think of no situation where I have a dereferenced variable containing another var name, i.e. where it would happen unexpected.
So I would say it's OK to be recursive.
(As I know me I would use it somewhen

Win11 Pro 23H2 Gerrman
Re: Dereference opereator in interpolation
...but:
as there is / there seems no way to disable it, you would never be able to prevent these multiple substitutions.
edit typos
as there is / there seems no way to disable it, you would never be able to prevent these multiple substitutions.
edit typos

Win11 Pro 23H2 Gerrman
Re: Dereference opereator in interpolation
1) Tested!
Will wait a bit before I delete the old/commented instructions
2) As long as there would be no ability to *prevent* recursive substitutions, I think it's OK that you didn't do it!
And once again: thanks!

Will wait a bit before I delete the old/commented instructions

2) As long as there would be no ability to *prevent* recursive substitutions, I think it's OK that you didn't do it!
And once again: thanks!

Win11 Pro 23H2 Gerrman
Re: Dereference opereator in interpolation
Thanks for the hint!
It seems nothing changed for a new installation.
That means: a new installation does not work with (all/some) old scripts. Bad for new users downloading old scripts :-(
Wouldn't it be helpful to define AID as an operand of the SETTING command - so any old script could be made working bei adding
This would be easy to explain, and old scripts could be made working by just adding this stmt, without any further manipulation.
It seems nothing changed for a new installation.
That means: a new installation does not work with (all/some) old scripts. Bad for new users downloading old scripts :-(
Wouldn't it be helpful to define AID as an operand of the SETTING command - so any old script could be made working bei adding
Code: Select all
setting AID 0; // or alike
Win11 Pro 23H2 Gerrman
-
- Site Admin
- Posts: 63451
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Dereference opereator in interpolation
By "old" you mean "at most 4 weeks", right?
FAQ | XY News RSS | XY Bluesky
Re: Dereference opereator in interpolation
You are right: I misinterpreted the dflt of AID as the general dflt of this setting! (Though the first chapter does explain it
)
(But I must say: I liked it!)
Before next misunderstanding: is AID only for the current script, or is it permanent?
(As you don't mention a .ini-setting it seems to be restricted to the current script? *Like* a
)

(But I must say: I liked it!)
Before next misunderstanding: is AID only for the current script, or is it permanent?
(As you don't mention a .ini-setting it seems to be restricted to the current script? *Like* a
setting
-operand 
Win11 Pro 23H2 Gerrman
-
- Site Admin
- Posts: 63451
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Dereference opereator in interpolation
Yes, restricted to the current script. If you really need dereferencing in interpolation (and it's only you so far
) you have to work for it and type 4 characters:

aid;
FAQ | XY News RSS | XY Bluesky
Re: Dereference opereator in interpolation
OK:
I thought about a wish for
(...I know what to do if a new script of mine starts to show
)
...and in the end it's only a few.
(The end: I will be out now.)
aid;
in each script (needing interpolation).I thought about a wish for
settingP aid 1;
- but if it's only me...(...I know what to do if a new script of mine starts to show
*$varname

...and in the end it's only a few.
(The end: I will be out now.)
Win11 Pro 23H2 Gerrman