Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^6: Perl6 Contest #2: P6 That Doesn't Look Like P5

by tall_man (Parson)
on Jun 08, 2005 at 18:17 UTC ( #464778=note: print w/replies, xml ) Need Help??


in reply to Re^5: Perl6 Contest #2: P6 That Doesn't Look Like P5
in thread Perl6 Contest #2: P6 That Doesn't Look Like P5

I don't believe it will ever be possible to put named parameters after slurpy parameters. From E06:

An important restriction on named arguments is that they cannot come before positional arguments, or after any arguments that are bound to a slurpy array. Otherwise, there would be no efficient, single-pass way of working out which unnamed arguments belong to which parameters. But apart from that one overarching restriction (which Larry likes to think of as a zoning law), we’re free to pass named arguments in any order we like. That’s a huge advantage in any subroutine that takes a large number of parameters, because it means we no longer have to remember their order, just their names.

So this looks like the reason for my bug also. Named parameters cannot come before *@lst (because it's positional) and they cannot come after (because it's slurpy) so the declaration is invalid.

By the way, the "+" for "named only" doesn't really mean it. I found this astonishing code in the test cases:

sub foo (+$x = 3) { $x } is(foo(4), 4, "using a named as a positional works");

If that is legal, what's the difference between a "+" prefix and a "?" prefix on a parameter?

Replies are listed 'Best First'.
Re^7: Perl6 Contest #2: P6 That Doesn't Look Like P5
by TimToady (Parson) on Jun 08, 2005 at 18:40 UTC
    It is not legal, and the test case is in error.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://464778]
help
Chatterbox?
[1nickt]: marioroy Yes, I am using it with MCE, as is Discipulus I believe. I was trying to work out how to make a cpanfile that would be smart enough to know which deps to require.
[1nickt]: See this code. (I expected to simply eval loading threads as a check, but weirdness happened with Perlbrew so it's a grep of -V ...)
[choroba]: Config might be better than grepping -V
[Corion]: Also see Config::V, which is less of that hackery, or that hackery hidden in a module ;)
[1nickt]: The problem was with Perlbrew
[Corion]: Whoops - Config::Perl::V
[1nickt]: I found that when using Perlbrew as recommended, with cpanminus in the system perl lib, such tests were failing to detect the data about the perl that was the install destination.

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2017-10-18 15:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (249 votes). Check out past polls.

    Notices?