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

f-interpolator should not inject %s needlessly #9784

Closed
scabug opened this issue May 18, 2016 · 6 comments · Fixed by scala/scala#10364
Closed

f-interpolator should not inject %s needlessly #9784

scabug opened this issue May 18, 2016 · 6 comments · Fixed by scala/scala#10364
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented May 18, 2016

When the f-interpolator winds up just concatenating strings, it should just use StringBuilder instead of String.format. This makes a big difference on scala-js.

These should be equivalent:

f"My name is $name"
"My name is " + name
@scabug
Copy link
Author

scabug commented May 18, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9784?orig=1
Reporter: @som-snytt
Affected Versions: 2.12.0-M3
See #8650

@scabug
Copy link
Author

scabug commented May 18, 2016

@som-snytt said:
f-interpolator should provide the optimal user experience for all your stringly needs.

@scabug
Copy link
Author

scabug commented May 18, 2016

@sjrd said:
Or even better: just plain old String.+, and let the back-end decide what's the best strategy to compile string concatenation. Spoiler: on JS that's not using StringBuilder, it's using JS' own string concatenation.

@scabug
Copy link
Author

scabug commented May 18, 2016

@sjrd said:
Btw, it would be really nice if s"" could do the same.

@scabug
Copy link
Author

scabug commented May 18, 2016

@som-snytt said:
Ah!

@som-snytt
Copy link

Bumping this, because now that s-interpolator is more reasonable, f-interpolator should translate normal interpolation (formatless) to string add. In particular, the semester project to bring f-interpolation to dotty should also do it.

@som-snytt som-snytt changed the title f-interpolator should build strings when feasible f-interpolator should not inject %s needlessly May 5, 2019
@lrytz lrytz modified the milestones: Backlog, 2.13.12 Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants