dispell#
Detach a wizard from the variable $ref points at.
Synopsis#
use Peta::XS ':magic';
dispell(\$x, $w); # true if $w was attached, false otherwise
What you get back#
True if this wizard’s attachment was found and removed, false if it was not attached. Idempotent: a second dispell of the same wizard returns false and changes nothing.
Contract#
Removes exactly this wizard’s attachment - other wizards on the same variable stay, and so does unrelated magic (a tie, for example). The attachment’s private data is released. The free callback does NOT run: dispelling is detachment, not destruction; free fires only when the variable itself dies.
Examples#
## scoped watching: attach, observe, detach
cast(\$config, $watch);
run_suspicious_code();
dispell(\$config, $watch); # $config is an ordinary scalar again
## wizards detach independently
cast(\$x, $w1);
cast(\$x, $w2);
dispell(\$x, $w1); # $w2 keeps firing
say scalar magic(\$x); # 1