How do I make deferencing work with set and unset?
Tried this:
Code: Select all
$c=13;
while($c>0){
$s = '$d'.$c;
set *$s, $c;
$c--;
}
Code: Select all
...
unset *$s;
$c--;
}
Code: Select all
$c=13;
while($c>0){
$s = '$d'.$c;
set *$s, $c;
$c--;
}
Code: Select all
...
unset *$s;
$c--;
}
Code: Select all
$var = '$a'; *$var = "TEST"; echo $a; //TESTCode: Select all
$var = '$a'; *$var = "TEST"; echo $a; //TESTCode: Select all
$var = '$a';Code: Select all
String a; // declaration, no initializisation
String var = "Test"; // declaration & initializisation
a = var;Code: Select all
$n = 4;
$a$n = 'text'; // sets $a4 to 'text'
echo $a$n; // shows contents of $a4Code: Select all
$name = 'abc';
$$name = 'text'; // sets $abc
echo $$name; // shows contents of $abc
Code: Select all
$name = '$abc';
*$name = 'text'; // sets $abc
echo eval($name); // shows contents of $abcCode: Select all
$vn = 4;
$vt = "caption";
$name = '$var' . $vn . $vt;
*$name = 'Title or so';
// ... some code, $vn and $vc will be independent: must recalculate $name!
$name = '$var' . $vn . $vt;
echo "var '$vn' '$vt' = '" . eval($name) . "'";
<<<--- ............................ --->>>
$vn = 4;
$vt = "caption";
$var$vn$vt = 'Title or so';
// ... some code, $vn and $vc will be independent: does not matter!
echo "var '$vn' '$vt' = '" . $var$vn$vt . "'";Quoting has always been optional so the following is entirely acceptable:PeterH wrote:2 versions of sample code
- first as it works now
- second with $a$b$c syntax:I think the second version looks simpler, and more direct.Code: Select all
$vn = 4; $vt = "caption"; $name = '$var' . $vn . $vt; *$name = 'Title or so'; // ... some code, $vn and $vc will be independent: must recalculate $name! $name = '$var' . $vn . $vt; echo "var '$vn' '$vt' = '" . eval($name) . "'"; <<<--- ............................ --->>> $vn = 4; $vt = "caption"; $var$vn$vt = 'Title or so'; // ... some code, $vn and $vc will be independent: does not matter! echo "var '$vn' '$vt' = '" . $var$vn$vt . "'";
It should not break old code if only allowed outside quotes?
Currently $a$b (or $var$vn$vt as above) outside of quotes is not allowed?
Code: Select all
$a = 1;
$b = 2;
$c = 3;
echo $a$b$c; // Echo's '123'.As far as I remember the $a$b$c outside quotes if wrong/illegal syntax since the time quoting was invented.TheQwerty wrote:Quoting has always been optional so the following is entirely acceptable:No idea how many old scripts rely on this method for operator-less concatenation, and sure it is only a true problem when the now dereferenced variable name is the same as existing variable names, but I don't like the idea of having to trace back variables to discover they are dereference earlier.Code: Select all
$a = 1; $b = 2; $c = 3; echo $a$b$c; // Echo's '123'.
That ambiguity alone makes it impossible for me to ever see how the second example is better. Is it clearer? Only if you know enough about the code - but that burden of knowledge is costly.
Isn't this particular problem also solved by the Set SC's reprocess flag?