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
unexpected parsing of "pp $_[0]" into "$_->pp([0])" #16793
Comments
From @djeriusCreated by @djeriusHowdy! The following behavior may simply be a byproduct of precedence rules, % perl -e 'pp $_[0]' and here's the deparse: which is not at all what I expected. Changing from $_ to a defined array $ perl -e 'my @X = ( 1 ); pp $X[0]' gives this bizarre deparse: $ perl -MO=Deparse -e 'my @X = ( 1 ); pp $X[0]' The backdrop of this is that I did equivalent to this: sub foo { Note the forgotten parenthises around the argument to T1::func. This resulted in a call of T1::func( $_, [0] ); or T1::func( 'no', [0] ); with no errors except garbage return from T1::func. Figuring out Perl Info
|
From @xenuOn Sat, 22 Dec 2018 13:24:18 -0800
It's called "indirect object syntax" and it's one of the worst perl It's possible to disable it using indirect.pm pragma from CPAN: https://metacpan.org/pod/indirect |
The RT System itself - Status changed from 'new' to 'open' |
From @demerphqNot sure that that fully explains things here, as $_ was not mentioned. It $_[0]->pp() But as the OP noted it does not get parsed that way at all. Yves On Sat, 22 Dec 2018, 22:37 Tomasz Konojacki <me@xenu.pl wrote:
|
From @djeriusOn Sat, Dec 22, 2018 at 4:52 PM yves orton via RT <perlbug-followup@perl.org>
Sorry, I should have noted that this is how I expected it to be parsed.
|
From @LeontOn Sat, Dec 22, 2018 at 10:25 PM Diab Jerius (via RT)
Indirect method calls are nasty like that :-(.
That is unexpected however.
|
From @djeriusOn Sat, Dec 22, 2018, 6:12 PM Leon Timmermans via RT <
Is the split between $_ and [0] expected? That's what surprised me. I would
|
From @LeontOn Sun, Dec 23, 2018 at 2:29 AM Diab Jerius <djerius@cpan.org> wrote:
Yes, that is what anyone would hope for in this particular case, but The problem here is that a situation where *three* terms may follow Even if this could be fixed (I suspect it can't; but don't know the |
From gm@qwurx.deFrom the keyboard of Leon Timmermans [23.12.18,06:03]:
First case nicely explained, but that doesn't explain the - yes, bizarre perl -MO=Deparse -e 'my @X=(1);pp $X[0]' where the $X is made into an array. It looks like the lexer, looking at perl -MO=Deparse -e 'my @X=(1);pp @X[0]' whereas an array in direct object notation resolves to its scalar value perl -e 'my @X=("foo","bar");@X->pp([0])' That the '_' identifier is treated specially comes at no surprise, but 0--gg- -- |
From Eirik-Berg.Hanssen@allverden.noOn Sun, Dec 23, 2018 at 2:03 PM shmem <gm@qwurx.de> wrote:
It may look like that, but are you sure it's not just a bug in the Compare: perl -MO=Deparse -e "our @X=(1); pp $X[0]; Clearly the presence of the lexical @X changes something ... but does it Either way, the deparse can't be right:
Eirik |
From @djeriusOn Sun, Dec 23, 2018 at 12:04 AM Leon Timmermans <fawaka@gmail.com> wrote:
Thanks for that very useful explanation. I didn't realize how tricky this |
From @djeriusOn Sat, Dec 22, 2018 at 4:37 PM Tomasz Konojacki via RT <
Thanks. I haven't used that syntax in so long I didn't recognize it. I'm no indirect 'global'; To sitecustomize.pl just to see how much chatter that generates. |
Migrated from rt.perl.org#133736 (status was 'open')
Searchable as RT133736$
The text was updated successfully, but these errors were encountered: