Skip to content

Instantly share code, notes, and snippets.

@gfldex
Created February 18, 2021 15:53
Show Gist options
  • Save gfldex/5f5b723090271a4fd4561d72ed7a45fc to your computer and use it in GitHub Desktop.
Save gfldex/5f5b723090271a4fd4561d72ed7a45fc to your computer and use it in GitHub Desktop.
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