A scalar with memory, or how to correctly `tie`
This does not help you get the functionality you want, but it does answer your specific questions for now:
say self.VAR.WHAT; # Why is this "Proxy" and not "HistoryProxy"?
I think this is because the Proxy
class is currently not set up to be subclassed. Its new
method basically does a Proxy.new
instead of a self.new
, so it misses the subclassing. Looking into that now.
self.VAR.SAVE( $c-value ); # Why does this not work?
self
is always decontainerized. So you're always seeing the underlying value. If you want to have the actual object, you will need to change the signature of the method
, e.g.:
STORE => method (\SELF: T $new-value) {
and then use:
SELF.VAR
But since the object isn't actually blessed as the subclass, this won't help you much anyway.
UPDATE: https://github.com/rakudo/rakudo/pull/3196 should allow subclassing of Proxy
objects in the future.
UPDATE: with https://github.com/rakudo/rakudo/commit/d00674b31c this Pull Request got merged. It should become available in the 2019.11 Rakudo compiler release.