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

Extra parameters not ACCEPTed when smartmatching sig with invocant #4333

Open
p6rt opened this issue Jun 19, 2015 · 2 comments
Open

Extra parameters not ACCEPTed when smartmatching sig with invocant #4333

p6rt opened this issue Jun 19, 2015 · 2 comments

Comments

@p6rt
Copy link

p6rt commented Jun 19, 2015

Migrated from rt.perl.org#125438 (status was 'new')

Searchable as RT125438$

@p6rt
Copy link
Author

p6rt commented Jun 19, 2015

From @skids

# Should a methodlike Signature ACCEPT extra named parameters?

# First, this is at least an LTA error but arguably should be True
bri@​atlas​:~/NetSight/pm6$ perl6 -e 'say so (1,2) ~~ :($a​: $b)'
Lexical with name 'self' does not exist in this frame
  in block <unit> at -e​:1

# So just to establish this workaround works first...
bri@​atlas​:~/NetSight/pm6$ perl6 -e 'say so (1,2) ~~ :(\self​: $b)'
True

# ...and now we see that a methodlike signature rejects extra nameds​:
bri@​atlas​:~/NetSight/pm6$ perl6 -e 'say so (1,2,​:a) ~~ :(\self​: $b)'
False

@p6rt
Copy link
Author

p6rt commented Dec 10, 2015

From @skids

This has sort of been swept under the rug by making it difficult to
make a signature literal with an invocant.

$ perl6 -e 'say so (1,2) ~~ :(\self​: $b)'
===SORRY!=== Error while compiling -e
Can only use the : invocant marker in the signature for a method
at -e​:1
------> say so (1,2) ~~ :(\self​: $b⏏)
  expecting any of​:
  constraint

There may eventually be a reason to do that, but for now it keeps anyone from
relying on the behavior there.

In the meantime we've made method signatures show the %*_

$ perl6 -e 'class foo { method bar (Any​: $b) { } }; my $s = foo.^find_method("bar").signature; $s .= clone; $s.perl.say; say so (1, 2, :a) ~~ $s'
:($​: $b, *%_)
True

Perhaps were we to ever allow methodish signature literals, we could say
it is the "method" declaration (or something in ClassHOW's handling of them,
really) that adds the *%_, and one has to add it explicitly in a :()

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