Skip to content

Method dispatch on String.split is too general #65

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

Closed
gzm0 opened this issue Dec 17, 2013 · 5 comments
Closed

Method dispatch on String.split is too general #65

gzm0 opened this issue Dec 17, 2013 · 5 comments
Assignees
Labels
bug Confirmed bug. Needs to be fixed.
Milestone

Comments

@gzm0
Copy link
Contributor

gzm0 commented Dec 17, 2013

The following line should dispatch split on WrappedString (after PIMPing).

println("a?b".split('?').toList)

However, the line yields List("a?b") rather than List("a", "b")

@sjrd
Copy link
Member

sjrd commented Dec 17, 2013

What's WrappedString?

@gzm0
Copy link
Contributor Author

gzm0 commented Dec 18, 2013

WrappedString does all the string-is-a-seq-of-chars magic. It's like a RichInt for String

@gzm0
Copy link
Contributor Author

gzm0 commented Dec 28, 2013

The split(_: Char) is (in this case) provided by StringOps, which implements the method using the \Q and \E escapes of Java Regexes. We have the option of:

  • Rewrite StringOps for Scala.js
  • Support \Q and \E

The latter is probably simpler in the long run, but unsure about this.

@sjrd
Copy link
Member

sjrd commented Dec 28, 2013

Supporting \Q and \E basically means implementing a lexer that would tokenize the string and untokenize it afterwards. I don't like it. But I don't like rewriting StringOps either (actually StringLike) :-s

I would opt for a very nasty hack, documented as being there for the sole purpose of supporting StringLike.split: in regex implem, just support \Qc\E with c being one character.

@gzm0
Copy link
Contributor Author

gzm0 commented Dec 28, 2013

I like that. Will implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug. Needs to be fixed.
Projects
None yet
Development

No branches or pull requests

2 participants