Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
use nqp;
class Metamodel::ProxyHOW is Metamodel::ClassHOW {
method compose(Mu $type-obj is raw) {
say composing a Metamodel::ProxyHOW;
my %m = $type-obj.^methods.map({ slip .name, $_ });
# $type-obj.^add_method('new', sub ($type) {
# nqp::create(nqp::decont($type));
# });
$type-obj.^set_container_spec(nqp::hash('fetch', %m<FETCH>, 'store', %m<STORE>));
self.Metamodel::ClassHOW::compose($type-obj, |%_);
self.Metamodel::ClassHOW::compose_repr($type-obj);
$type-obj
}
}
package EXPORTHOW {
package DECLARE {
constant proxy = Metamodel::ProxyHOW;
}
}
use DeclaratorProxy;
proxy Proxy {
has $.a-var;
method FETCH() { $.a-var }
method STORE(\v) { $.a-var = v }
}
proxy Q is Proxy {
}
Q.new;
@gfldex
Copy link
Author

gfldex commented Feb 18, 2021

OUTPUT:

composing a Metamodel::ProxyHOW
composing a Metamodel::ProxyHOW
Cannot invoke object with invocation handler in this context
in block at /home/dex/projects/raku/proxy-moxy.raku line 13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment