Skip to content

Instantly share code, notes, and snippets.

@peschwa
Created November 1, 2015 13:36
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 peschwa/2d25e44bcabecf1d6ced to your computer and use it in GitHub Desktop.
Save peschwa/2d25e44bcabecf1d6ced to your computer and use it in GitHub Desktop.
$ cat Foo.pm
module Foo {
my $_marshal_proto = my proto _marshal(|c) {*};
$_marshal_proto.add_dispatchee(sub (Int $) { "Int" });
sub get_marshal_proto is export is rw { $_marshal_proto }
sub marshal(Any $x) is export {
say $_marshal_proto($x)
}
}
$ ./perl6-m -I. -MFoo -e'get_marshal_proto.add_dispatchee(sub (Str $) { "Str" }); marshal("foo")'
Str
@jonathanstowe
Copy link

Shiip it! 👍 ;-)

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