Created
February 18, 2021 15:53
-
-
Save gfldex/5f5b723090271a4fd4561d72ed7a45fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use DeclaratorProxy; | |
proxy Proxy { | |
has $.a-var; | |
method FETCH() { $.a-var } | |
method STORE(\v) { $.a-var = v } | |
} | |
proxy Q is Proxy { | |
} | |
Q.new; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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