You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> The following discussion from november 2015 was linked in ticket
> https://rt.perl.org/Ticket/Display.html?id=125784 which I'm going
> to close.
>
> I'm opening this separate ticket for the differing behaviour
> of rakudo-moar and rakudo-jvm with regard to using a negative
> startposition for index (and rindex).
>
> <bartolin> lizmat: earlier today I found this differing behaviour
> for moar and jvm:
> <bartolin> r: say index("xxy", "y", -1)
> <camelia> rakudo-moar: OUTPUT«Nil»
> <camelia> ..rakudo-jvm 0b6328: OUTPUT«2»
> <bartolin> do you think moar is right here?
> * lizmat looks into it
> <bartolin> lizmat++
> <lizmat> r: use nqp; say nqp::index("xxy","y",-1)
> <camelia> rakudo-jvm 0b6328: OUTPUT«2»
> <camelia> ..rakudo-moar: OUTPUT«-1»
> <lizmat> looks like a difference in implementation of nqp::index
> <lizmat> r: use nqp; say nqp::index("xxy","y",0)
> <camelia> rakudo-moar, rakudo-jvm 0b6328: OUTPUT«2»
> <lizmat> bartolin: seems worthy of an NQP ticket
> <lizmat> or perhaps just a rakudobug :-)
> <bartolin> lizmat: and what do you think is the "better" answer?
> Perl 5 allows negative start positions, if I'm not mistaken.
> <lizmat> yes, but P5 also allows to use -1 to indicate from end
> <lizmat> so perhaps it should just fail on a negative position
> <bartolin> I see. I'll open a RT for this (probably a bit later).
> <bartolin> thanks for looking!
With a followup narrowing this down to pure nqp behavior:
> Sorry, I got a bit confused:
>
> The different behavior for routines index and rindex with negative startposition between rakudo-moar and rakudo-jvm was fixed (see https://rt.perl.org/Ticket/Display.html?id=126700).
>
> What's still relevant is the different implementation of nqp::index:
>
> $ perl6-m -e 'use nqp; say nqp::index("xxy","y",-1)'
> -1
>
> $ perl6-j -e 'use nqp; say nqp::index("xxy","y",-1)'
> 2
>
> Output generated with Rakudo version 2016.03-110-g5bfc8fb.
Which is still happening today:
15:46 < unmatched}> r: use nqp; say nqp::index("xxy","y",-1)
15:46 < camelia> rakudo-moar 3bea9d: OUTPUT«-1»
15:46 < camelia> ..rakudo-jvm cd19db: OUTPUT«2»
The text was updated successfully, but these errors were encountered:
Originally opened as https://rt.perl.org/Ticket/Display.html?id=127913 by Christian Bartolomaeus
Which is still happening today:
The text was updated successfully, but these errors were encountered: