On 2025-02-04 17:31, Larry Garfield wrote:


However, there is a concern that it wouldn't be self-evident to PHP devs, and the 
variable binding side should have the extra marker.  Ilija has suggested &, as 
that's what's used for references, which would result in:

$b = '12';

if ($arr is ['a' => &$a, 'b' => $b]) {
     print $a;
}

There are two concerns with this approach.

1. The & could get confusing with an AND conjunction, eg, `$value is int & &$x` 
(which is how you would bind $value to $x iff it is an integer).
2. In practice, binding is almost certainly going to be vastly more common than 
pinning, so it should likely have the shorter syntax.


There is already something analogous, in the sense of "binding to someone else's variable" in named parameters. Running with that analogy gives:

$b = '12';
 if ($arr is ['a' => a:, 'b' => $b]) {
      print $a;
 }

Reply via email to