Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'use' named arg munging is evil #4856

Open
p6rt opened this issue Dec 13, 2015 · 1 comment
Open

'use' named arg munging is evil #4856

p6rt opened this issue Dec 13, 2015 · 1 comment

Comments

@p6rt
Copy link

p6rt commented Dec 13, 2015

Migrated from rt.perl.org#126893 (status was 'new')

Searchable as RT126893$

@p6rt
Copy link
Author

p6rt commented Dec 13, 2015

From @LLFourn

perl6 -e 'use Test do { Date.new(year => 2015); ()}'

===SORRY!===
Default constructor for 'Date' only takes named arguments

This example is fairly golfed, but you can run into this in the wild.

Consider a module that has an EXPORT sub and takes positional arguments. If
you tried to do

use MyModule Date.new( year => 2015) # you will get the error

I don't really get why the arguments to 'use' don't just use normal
invocation semantics, with the positionals taken out and passed to export
and the named used for normal importing.

unless $*IN_DECL eq 'use' || $*IN_DECL eq 'no' || $*IN_DECL eq 'import' ||
$*IN_RETURN {

  $_[2].named($name);

  }
This is the line in Actions.nqp that makes 'use' special.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant