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

required named before optional positional parameter produces confusing error message #2070

Closed
p6rt opened this issue Aug 14, 2010 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Aug 14, 2010

Migrated from rt.perl.org#77220 (status was 'resolved')

Searchable as RT77220$

@p6rt
Copy link
Author

p6rt commented Aug 14, 2010

From @jkeenan

The New York City Rakudo Star study group is working its way through
the Using Perl PDF from Rakudo's github site. Working through the
examples in Chapter 4, Subs and Signatures, we believe we have
identified a case where the code example does not work​:

At bottom of page 34, we see​:

sub design-ice-cream-mixture(​:$name!, $base = 'Vanilla') {
  say "Creating a new recipe named $name!";
  }

design-ice-cream-mixture(name => 'Plain');

FAILS with​:

===SORRY!===
Can't put required parameter after variadic parameters at line 3,
near ") {\n sa"

However, if we but 'base' before 'name' in the signature, it works​:

sub design-ice-cream-mixture($base = 'Vanilla', :$name!) {
  say "Creating a new recipe named $name!";
  }

design-ice-cream-mixture(name => 'Plain');

This works.

Can anyone confirm that it is merely the code exammple on page 34
which is incorrect?

Thank you very much.

kid51

@p6rt
Copy link
Author

p6rt commented Aug 15, 2010

From @masak

On Sat Aug 14 11​:33​:18 2010, jkeen@​verizon.net wrote​:

The New York City Rakudo Star study group is working its way through
the Using Perl PDF from Rakudo's github site. Working through the
examples in Chapter 4, Subs and Signatures, we believe we have
identified a case where the code example does not work​:

At bottom of page 34, we see​:

sub design-ice-cream-mixture(​:$name!, $base = 'Vanilla') {
say "Creating a new recipe named $name!";
}

design-ice-cream-mixture(name => 'Plain');

FAILS with​:

===SORRY!===
Can't put required parameter after variadic parameters at line 3,
near ") {\n sa"

However, if we but 'base' before 'name' in the signature, it works​:

sub design-ice-cream-mixture($base = 'Vanilla', :$name!) {
say "Creating a new recipe named $name!";
}

design-ice-cream-mixture(name => 'Plain');

This works.

Can anyone confirm that it is merely the code exammple on page 34
which is incorrect?

Confirmed​: the error message is wrong, but it's right in that one cannot put this kind of thing
after that kind of thing​: namely, one cannot put a named parameter after a positional one in a
signature.

@p6rt
Copy link
Author

p6rt commented Aug 15, 2010

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

@p6rt
Copy link
Author

p6rt commented Aug 23, 2010

From @moritz

Thanks for the report, I've now fixed the example in the book.

@p6rt
Copy link
Author

p6rt commented Oct 1, 2011

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Oct 1, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant