##PowerShell##
PowerShell
This creates an object whose state
property is the names of the variables that point to the object.
$a = @{}| Add-Member -MemberType:16 -PassThru state -Value {
(gv|?{$this -eq $_.Value}|%{$_.Name}) -join ','}
'Before: ' + $a.state
$b = $a
'After: ' + $a.state
Output
Before: a,this
After: a,b,this
Note: This doesn't work if the assignment happens in a child scope.
'Before: ' + $a.state
&{$b = $a}
'After: ' + $a.state
Outputs
Before: a,this
After: a,this