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

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

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



Subject: [BUG] sub-signature unpacking does not work for lazy seq
From: Zhenyi Zhou <zhouzhen1 [...] gmail.com>
Date: Thu, 1 Oct 2015 11:54:09 +0800
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 452b
In S06-routines.pod there is an example of head and tail

sub head(*$head, *@tail)         { return $head }
sub neck(*$head, *$neck, *@tail) { return $neck }
sub tail(*$head, *@tail)         { return @tail }
With present rakudo below tail(1 .. Inf) returns [], not [2..Inf]
@fromtwo = tail(1..Inf);        # @fromtwo contains a lazy [2..Inf]

I tried below, it can work. 
@fromtwo = tail(|(1..5));
But this just hangs. 
@fromtwo = tail(|(1..Inf));

Download (untitled) / with headers
text/plain 508b
This is because interpreting `*$head` as a "slurpy scalar parameters" the way S06 intended, has never been implemented. Rakudo seems to interpret `*$head` as a normal `$head` parameter, so you need to explicitly interpolate your input range into the argument list using | if you want it to be unpacked. Ideally, Rakudo should throw an error when it encounters the `*$head` syntax, until the S06 behavior is implemented. (The fact that your last example hangs is a separate bug, covered by ticket #128201)
Download (untitled) / with headers
text/plain 254b
FYI, unpacking a slurpy parameter can already be done using a subsignature. The following two should behave identically, but only the first is already implemented: sub foo (*@ [$head, *@tail]) { } # works sub foo (*$head, *@tail) { } # NYI


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