Skip Menu |
Report information
Id: 127143
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: cpan [at] zoffix.com
Cc:
AdminCc:

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



Subject: Different Behaviour With/Without Commas in Sub/Method Calls and slipped hashes
Download (untitled) / with headers
text/plain 886b
I think this is related to https://rt.perl.org/Ticket/Display.html?id=127134 The code below shows three scenarious: 1) Subcall with two named args of same name without a comma between them, with the latter overriding the former 2) Subcall with a slipped hash and a named parameter of same name as the one in the hash, NOT separated by comma: the named parameter does NOT override the value 3) Subcall with a slipped hash and a named parameter of same name as the one in the hash, SEPARATED by comma: the named parameter DOES override the value <Zoffix> m: sub SUB(:$foo) {say "[$foo]" }; my %args = :foo<foo>; SUB :foo<foo> :foo<newfoo>; SUB |%args :foo<newfoo>; SUB |%args, :foo<newfoo>; <camelia> rakudo-moar 7d4cdb: OUTPUT«[newfoo]␤[foo]␤[newfoo]␤» The Expected Thing™ would be that slipped hash behaves same as regular named args or at least an error/warning is shown.
Download (untitled) / with headers
text/plain 640b
Without the comma, the colonpair is in infix position, which means it applies to the prefix unary | operator. So whether this should be an error or "work" depends on what we can teach the | operator to do with fake_infix adverbs it is passed. Note if we fix | to use fake infix adverbs, then we create the problem that |(1,1),(2,2),:f :g will be 1,1,:g,(2,2),:f. It might be best to teach | to throw when it is handed such things. There are several other operators that will find themselves in the same situation... especially we have other tickets about = which gets tricky due to the difference between list and scalar assignment.
Download (untitled) / with headers
text/plain 301b
On Mon, 21 May 2018 09:13:15 -0700, bri@abrij.org wrote: Show quoted text
> Note if we fix | to use fake infix adverbs, then we create the problem > that |(1,1),(2,2),:f :g will be 1,1,:g,(2,2),:f.
...sorry that might be OK due to the "first pair in term position"... but |(1,1),(2,2),1 :g will be 1,1,:g,(2,2),1.


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