Skip to content

Instantly share code, notes, and snippets.

@gfldex
Created October 25, 2016 12:00
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 gfldex/a04a57109892b31f3f2e14cbd0235714 to your computer and use it in GitHub Desktop.
Save gfldex/a04a57109892b31f3f2e14cbd0235714 to your computer and use it in GitHub Desktop.
use v6;
use lib '.';
# - require will return the class with the same name as the module name
# - all lookups of modules loaded via required have to be dynamic
# - type names are imported at runtime and are not available for normal type checks
# - smart match between type objects and dynamic lookups works
subset C where ::('M::C');
my C $context = try {
CATCH { default { .note } };
require ::('M');
::('M::C')
};
dd $context.HOW.^methods.elems;
dd $context.HOW.shortname($context);
unit module M;
class C is export { method m { 'method C::m' } };
class D is export { method m { 'method D::m' } };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment