Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scalar slurpies?

Tags:

raku

rakudo

As far as I (and the docs) know, slurpies can only be used with array or hash parameters. However, I recently typo'ed the syntax and entered what looks like it would be the syntax for a scalar slurpy. Much to my surprise, this didn't result in a syntax error. After some experimentation, I determined that the following are all allowed:

sub f(*$a)  {}
sub g(**$a) {}
sub h(+$a)  {}

I couldn't, however see what (if anything) this syntax did. So what's going on? Is this an under-documented feature? A bug that's causing invalid syntax not to throw an error? Something else altogether?

like image 502
codesections Avatar asked Feb 13 '21 23:02

codesections


1 Answers

So what's going on? Is this an under-documented feature? A bug that's causing invalid syntax not to throw an error? Something else altogether?

Its undocumented and broken behaviour. It was speculated it would have different behaviour. It's a filed bug. See Slurpy scalar parameters (and duplicate https://github.com/Raku/old-issue-tracker/issues/5656) for further discussion.

like image 85
raiph Avatar answered Oct 11 '22 02:10

raiph