Navigation Menu

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

'self' doesn't force item context in Rakudo #2680

Closed
p6rt opened this issue Mar 21, 2012 · 4 comments
Closed

'self' doesn't force item context in Rakudo #2680

p6rt opened this issue Mar 21, 2012 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Mar 21, 2012

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

Searchable as RT111914$

@p6rt
Copy link
Author

p6rt commented Mar 21, 2012

From @masak

<moritz> on a completely different topic, S12 says that 'self' is
always assumed to be in item context
<moritz> why is that the case? that's the role of the $ sigil, which
isn't there on 'self'
<masak> the role of the $ sigil is forcing item context.
<masak> 'self', by current spec, has that built-in.
<moritz> yes, but why?
<masak> I don't know. maybe because of some psychological expectation
that 'self' is a single thing?
<moritz> we've extra eliminiated the $ from (|$foo) variables, because
it doesn't fit the "$ means item" philosphy
<masak> do you have a use case where 'self' being in item context is
cumbersome or unfortunate?
<masak> can you *guarantee* that a lot of existing Perl 6 code (in
CORE, for example) doesn't rely on the assumption that 'self' is in
item context? :)
<moritz> r​: my @​a = 1, 2; .say for @​a.push​: 3
<p6eval> rakudo 1a468d​: OUTPUT«1␤2␤3␤»
<moritz> push simply returns self. Very convenient, and only possible
because rakudo doesn't enforce the contnext
<masak> moritz​: so you're saying that Rakudo isn't to spec in that regard?
<moritz> masak​: correct
* masak submits rakudobug
* masak grins
<moritz> nom​: class A is Array { method identity { self } }; my @​a :=
A.new; @​a = 3, 4, 5; .say for @​a.identity
<p6eval> rakudo 1a468d​: OUTPUT«3␤4␤5␤»
<moritz> there you go, without reference to any core thing
<benabik> r​: my @​a = 1,2; .say for $(@​a.push​: 3)
<p6eval> rakudo 1a468d​: OUTPUT«1 2 3␤»

@p6rt
Copy link
Author

p6rt commented Jan 12, 2015

From @jnthn

On Wed Mar 21 08​:38​:33 2012, masak wrote​:

<moritz> on a completely different topic, S12 says that 'self' is
always assumed to be in item context
<moritz> why is that the case? that's the role of the $ sigil, which
isn't there on 'self'
<masak> the role of the $ sigil is forcing item context.
<masak> 'self', by current spec, has that built-in.
<moritz> yes, but why?
<masak> I don't know. maybe because of some psychological expectation
that 'self' is a single thing?
<moritz> we've extra eliminiated the $ from (|$foo) variables, because
it doesn't fit the "$ means item" philosphy
<masak> do you have a use case where 'self' being in item context is
cumbersome or unfortunate?
<masak> can you *guarantee* that a lot of existing Perl 6 code (in
CORE, for example) doesn't rely on the assumption that 'self' is in
item context? :)
<moritz> r​: my @​a = 1, 2; .say for @​a.push​: 3
<p6eval> rakudo 1a468d​: OUTPUT«1␤2␤3␤»
<moritz> push simply returns self. Very convenient, and only possible
because rakudo doesn't enforce the contnext
<masak> moritz​: so you're saying that Rakudo isn't to spec in that regard?
<moritz> masak​: correct
* masak submits rakudobug
* masak grins
<moritz> nom​: class A is Array { method identity { self } }; my @​a :=
A.new; @​a = 3, 4, 5; .say for @​a.identity
<p6eval> rakudo 1a468d​: OUTPUT«3␤4␤5␤»
<moritz> there you go, without reference to any core thing
<benabik> r​: my @​a = 1,2; .say for $(@​a.push​: 3)
<p6eval> rakudo 1a468d​: OUTPUT«1 2 3␤»

As of spec commit 8284cda, the current Rakudo behavior is now correct. There's also a test in roast commit 0ffea18.

/jnthn

@p6rt
Copy link
Author

p6rt commented Jan 12, 2015

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

@p6rt p6rt closed this as completed Jan 12, 2015
@p6rt
Copy link
Author

p6rt commented Jan 12, 2015

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

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant