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

Str.trans grabs callers $/ for unknown reason #6615

Open
p6rt opened this issue Oct 14, 2017 · 3 comments
Open

Str.trans grabs callers $/ for unknown reason #6615

p6rt opened this issue Oct 14, 2017 · 3 comments

Comments

@p6rt
Copy link

p6rt commented Oct 14, 2017

Migrated from rt.perl.org#132302 (status was 'open')

Searchable as RT132302$

@p6rt
Copy link
Author

p6rt commented Oct 14, 2017

From @zoffixznet

IRC​: https://irclog.perlgeek.de/perl6-dev/2017-10-14#i_15302654

1) Spotted that Str.trans grabs caller's $/ with $/ := nqp​::getlexcaller('$/')
  The same is not done for Cool.trans candidate, so presumably that makes whatever
  feature needs caller's $/ broken for Cool, while working for Str. However...

2) Why does Str.trans grabs caller's $/ in the first place? The commit that added
  it seems to claim to fix something that isn't meant to work as tr/// replaces per
  char and doesn't use special regex syntax (basically, author of the commit seems
  to be confusing it with s///).

  So I tried removing all of the $/ business from Str.trans, but that caused 2 tests
  to fail, one of which does something like this​:

  <Zoffix__> m​: say '"foo & bar"'.trans(/(' '+)/ => {' ' ~ (' ' x ($0.chars - 1))}, /(\W)/ => {"&#{ord($0)};"}); say $/
  <camelia> rakudo-moar de2b9ff72​: OUTPUT​: «&#​34;foo  &#​38;   bar&#​34;␤Nil␤»

  As can be seen from the eval above, while the $/ is used internally for trans stuff, the trans's caller's $/ is not
  set to anything. So unless I'm misunderstanding something, at least the part in Str.trans's proto that grabs caller's $/
  and possibly some other occurrences inside Str.trance need to be removed as they're useless wasted cycles.

  However, if there *is* some reason for why Str.trans proto (and routine) grab caller's $/, the same thing needs to be added
  to Cool.trans, to make it work right too.

[1] rakudo/rakudo@ec79843
[2] https://gist.github.com/zoffixznet/56ee3544201dbd18a419514ed70a782e

@p6rt
Copy link
Author

p6rt commented Oct 14, 2017

From @geekosaur

On Sat, Oct 14, 2017 at 1​:15 PM, Zoffix Znet <perl6-bugs-followup@​perl.org>
wrote​:

2) Why does Str.trans grabs caller's $/ in the first place? The commit
that added
it seems to claim to fix something that isn't meant to work as tr///
replaces per
char and doesn't use special regex syntax (basically, author of the
commit seems
to be confusing it with s///).

Are you sure this isn't just a copypasto?

--
brandon s allbery kf8nh sine nomine associates
allbery.b@​gmail.com ballbery@​sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

@p6rt
Copy link
Author

p6rt commented Oct 14, 2017

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

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