Skip to content

Instantly share code, notes, and snippets.

@scovit
Created September 15, 2017 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scovit/d4dc4bd73022a63c71bb2b500b543212 to your computer and use it in GitHub Desktop.
Save scovit/d4dc4bd73022a63c71bb2b500b543212 to your computer and use it in GitHub Desktop.
my $value := 42;
sub fetch($cont) { nqp::say("cuius"); $value }
sub store($cont, $new) { nqp::say("gratur"); $value := $new }
class SomeCont { }
nqp::setcontspec(SomeCont, 'code_pair', nqp::hash(
'fetch', &fetch,
'store', &store
));
my $cont := nqp::create(SomeCont);
nqp::say(nqp::decont($cont) == 42);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment