Skip Menu |
Report information
Id: 126893
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: lloyd.fourn [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: 'use' named arg munging is evil
To: "rakudobug [...] perl.org" <rakudobug [...] perl.org>
Date: Sun, 13 Dec 2015 15:06:45 +0000
From: Lloyd Fournier <lloyd.fourn [...] gmail.com>
Download (untitled) / with headers
text/plain 757b

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.




This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org