Skip to content

Instantly share code, notes, and snippets.

@lucs
Created December 9, 2015 12:03
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 lucs/d2fba5bec39f8f677f4f to your computer and use it in GitHub Desktop.
Save lucs/d2fba5bec39f8f677f4f to your computer and use it in GitHub Desktop.
In Perl 5, arbitrary data could be passed to a module's import()
function by doing "use Foo ('some', 'data')".
How is something similar (passing arbitrary data to a module when
'use'ing it) done in Perl 6?
I tried this, unsuccessfully:
"Foo.pm6":
unit module Foo;
my $val;
sub EXPORT ($x) {
$val = $x;
}
sub val () {
"<$val>";
}
"foo.pl6":
use v6;
use lib '.';
use Foo 42;
# Expecting "<42>␤";
say Foo::val;
Run "perl6 foo.pl6":
===SORRY!=== Error while compiling .../foo.pl6
Error while importing from 'Foo':
no EXPORT sub, but you provided positional argument in the 'use' statement
at .../foo.pl6:3
------> use Foo 42⏏;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment