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

Something doesn't work in hash indexing through a closure in Rakudo #461

Closed
p6rt opened this issue Dec 6, 2008 · 8 comments
Closed

Something doesn't work in hash indexing through a closure in Rakudo #461

p6rt opened this issue Dec 6, 2008 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Dec 6, 2008

Migrated from rt.perl.org#61106 (status was 'rejected')

Searchable as RT61106$

@p6rt
Copy link
Author

p6rt commented Dec 6, 2008

From @masak

Rakudo r33577 responds strangely to the following program​:

$ perl6 -e 'my $locator = method { .<here> }; my %h = { here => "foo"
}; say %h.$locator'
get_pmc_keyed() not implemented in class 'Undef'
[...]

I'd expect it to output "foo".

@p6rt
Copy link
Author

p6rt commented Dec 7, 2008

From @moritz

On Sat Dec 06 14​:12​:20 2008, masak wrote​:

Rakudo r33577 responds strangely to the following program​:

$ perl6 -e 'my $locator = method { .<here> }; my %h = { here => "foo"
}; say %h.$locator'
get_pmc_keyed() not implemented in class 'Undef'
[...]

I'd expect it to output "foo".

Is it actually specified that an anonymous method should receive the
invocant as $_? if yes, where?

If you say 'self.<here>' instead, the output is 'foo', as I'd expect it.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Dec 7, 2008

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

@p6rt
Copy link
Author

p6rt commented Dec 7, 2008

From @masak

Moritz (>), Carl (>>)​:

Rakudo r33577 responds strangely to the following program​:

$ perl6 -e 'my $locator = method { .<here> }; my %h = { here => "foo"
}; say %h.$locator'
get_pmc_keyed() not implemented in class 'Undef'
[...]

I'd expect it to output "foo".

Is it actually specified that an anonymous method should receive the
invocant as $_? if yes, where?

Yes, here​:

<http://perlcabal.org/syn/S12.html#line_279>

@p6rt
Copy link
Author

p6rt commented Dec 7, 2008

From @moritz

On Sun Dec 07 04​:33​:27 2008, masak wrote​:

Moritz (>), Carl (>>)​:

Rakudo r33577 responds strangely to the following program​:

$ perl6 -e 'my $locator = method { .<here> }; my %h = { here => "foo"
}; say %h.$locator'
get_pmc_keyed() not implemented in class 'Undef'
[...]

I'd expect it to output "foo".

Is it actually specified that an anonymous method should receive the
invocant as $_? if yes, where?

Yes, here​:

<http://perlcabal.org/syn/S12.html#line_279>

Thanks for the pointer, I've turned a similar thing into a test in
t/spec/S12-methods/indirect_notation.t

Moritz

@p6rt
Copy link
Author

p6rt commented Feb 13, 2009

From @jnthn

On Sun Dec 07 04​:33​:27 2008, masak wrote​:

Moritz (>), Carl (>>)​:

Rakudo r33577 responds strangely to the following program​:

$ perl6 -e 'my $locator = method { .<here> }; my %h = { here => "foo"
}; say %h.$locator'
get_pmc_keyed() not implemented in class 'Undef'
[...]

I'd expect it to output "foo".

Is it actually specified that an anonymous method should receive the
invocant as $_? if yes, where?

Yes, here​:

<http://perlcabal.org/syn/S12.html#line_279>

That doesn't actually say your example should work. It mentions​:

  $locator = { .<here> }
  $obj.$locator # $obj<here>

Which is a closure, not an anonymous method, and when it does mention
the anonymous method syntax, it uses self. Plus I don't see anywhere
else in S12 that it states that the invocant is in $_ by default for a
method. Asked TimToady to confirm either way, then will either implement
that if it's meant to be implemented, or reject the ticket (and remove
the incorrect test) otherwise.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Feb 13, 2009

From @jnthn

On Fri Feb 13 06​:05​:01 2009, jnthn@​jnthn.net wrote​:

On Sun Dec 07 04​:33​:27 2008, masak wrote​:

Moritz (>), Carl (>>)​:

Rakudo r33577 responds strangely to the following program​:

$ perl6 -e 'my $locator = method { .<here> }; my %h = { here => "foo"
}; say %h.$locator'
get_pmc_keyed() not implemented in class 'Undef'
[...]

I'd expect it to output "foo".

Is it actually specified that an anonymous method should receive the
invocant as $_? if yes, where?

Yes, here​:

<http://perlcabal.org/syn/S12.html#line_279>

That doesn't actually say your example should work. It mentions​:

$locator = \{ \.\<here> \}
$obj\.$locator            \# $obj\<here>

Which is a closure, not an anonymous method, and when it does mention
the anonymous method syntax, it uses self. Plus I don't see anywhere
else in S12 that it states that the invocant is in $_ by default for a
method. Asked TimToady to confirm either way, then will either implement
that if it's meant to be implemented, or reject the ticket (and remove
the incorrect test) otherwise.

TimToady confirmed that in methods we don't $_ := self by default, so
rejecting this ticket and removed the bad test.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Feb 13, 2009

@jnthn - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Feb 13, 2009
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