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

Slurpy scalar parameters #4609

Open
p6rt opened this issue Oct 1, 2015 · 4 comments
Open

Slurpy scalar parameters #4609

p6rt opened this issue Oct 1, 2015 · 4 comments
Labels
LTA Less Than Awesome; typically an error message that could be better NYI Features not yet implemented

Comments

@p6rt
Copy link

p6rt commented Oct 1, 2015

Migrated from rt.perl.org#126227 (status was 'open')

Searchable as RT126227$

@p6rt
Copy link
Author

p6rt commented Oct 1, 2015

From zhouzhen1@gmail.com

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));

@p6rt
Copy link
Author

p6rt commented May 20, 2016

From @smls

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)

@p6rt
Copy link
Author

p6rt commented May 20, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented May 21, 2016

From @smls

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

@p6rt p6rt added LTA Less Than Awesome; typically an error message that could be better NYI Features not yet implemented labels Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTA Less Than Awesome; typically an error message that could be better NYI Features not yet implemented
Projects
None yet
Development

No branches or pull requests

1 participant