Created
December 9, 2015 12:03
-
-
Save lucs/d2fba5bec39f8f677f4f 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
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