Skip to content

Conversation

@som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Jun 17, 2016

Something like that.

This has -language:-future.noStringPlus enable local implicit, where String.+ is not installed but is tacked on when typecheck fails, on the conservative theory that extra implicit searches for string concat would hurt compilation time for status quo. But that theory is not tested, so maybe there's no reason to be conservative.

@soc
Copy link
Contributor

soc commented Jun 21, 2016

I'm sympathetic to the idea, but I think this piecemeal introduction of language options and settings does more harm than good:

  • With this going in, we would have two vastly different ways of "doing the same thing" from a dev perspective depending on where exactly the + comes from. I think that's rather confusing.
  • Is there any reasonable benefit derived from the ability to disable one + but not the other?
  • I'd rather have one option that gets rid of all String-related + methods, combined with appropriate migration tools.
  • (What's the reason this is named noStringPlus instead of noStringAdd? Is this some kind of distinction between + on String and + on Any?)

@som-snytt
Copy link
Contributor Author

@soc I think you're saying, why are there two mechanisms for String.+ and the Predef.any2stringadd conversion? Besides historical reasons?

An implicit Predef.string2anyadd would be a no-op currently and unify the mechanisms under future.noStringPlus. Probably the folks who use these things know what they're doing and remain uncowed. Probably they are -language:future._ -Yno-predef anyway.

However, I haven't looked at whether the backend gets to do something efficient with String.$concat if there's an intervening conversion.

The operators that haven't been mentioned are the primitive +(String). (c: Char) + "".

It's called noStringPlus because the explorer who gets there first gets to name it. Also, + is $plus.

@dwijnand
Copy link
Member

String.$concat becomes StringBuilder calls in the backend:

else if (code == scalaPrimitives.CONCAT) genStringConcat(tree)

Also I don't mind if it's called add or plus, I just want it to not compile :)

@som-snytt
Copy link
Contributor Author

@dwijnand My concern about how it's encoded was that an implicit wrapper might not be completely eliminated. Also, I learned on Scala-JS it's just plus. https://issues.scala-lang.org/browse/SI-9784

@dwijnand
Copy link
Member

Interesting.

* at the end of the typechecking run for the enclosing unit. This
* is done to avoid potential cyclic reference errors by implicits
* that are forced too early.
* @param isAnOptInFeature Indicates if the feature is opt-in or not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't what the parameter is called anymore

@dwijnand
Copy link
Member

dwijnand commented Jul 6, 2016

@som-snytt feel free to fold my commit if you'd like

@som-snytt
Copy link
Contributor Author

@dwijnand no way, it's your fault this ball got rolling! Besides, it already has a green check.

@adriaanm adriaanm self-assigned this Aug 2, 2016
@SethTisue SethTisue added the release-notes worth highlighting in next release notes label Aug 9, 2016
@adriaanm
Copy link
Contributor

adriaanm commented Aug 9, 2016

I'm sorry that we were not able to give this the review/discussion attention it deserved, but I unfortunately don't think we can include this in 2.12.0. It's an exciting addition to the feature flags, but the design space is big enough to warrant some more exploration. As a compromise, I propose we do this exploration under a -Y flag in 2.12.x and, once baked, SIP it and expose it as a feature flag in 2.13.

dwijnand and others added 4 commits October 9, 2016 18:03
Conflicts:

	src/compiler/scala/tools/nsc/typechecker/Typers.scala
The multichoice setting wildcard behaves like import syntax.

Using `-language:_` enables all unprefixed feature settings,
and `-language:experimental._` enables the experimental ones.

For simplicity, we only exploit one level of nesting.

This allows `-language:future._` settings which should not
be automatically enabled under `-language:_`.
For controlling future syntax changes.
@som-snytt som-snytt force-pushed the topic/language-future branch from 057ee47 to a531d68 Compare October 10, 2016 01:15
@som-snytt
Copy link
Contributor Author

/rebuild

@SethTisue SethTisue modified the milestones: 2.12.2, 2.12.1 Nov 15, 2016
@SethTisue SethTisue added the WIP label Nov 15, 2016
@adriaanm
Copy link
Contributor

As I said, I'm open to a 2.12.x PR that introduces a -Y flag to experiment with this, but ultimately the full solution will require a SIP and a 2.13 target.

@adriaanm adriaanm closed this Feb 16, 2017
@som-snytt
Copy link
Contributor Author

OK, thanks, a lot of old girlfriends said that and I wish I'd listened when my wife said it would need a sip and a different target. I'll ask @dwijnand and the other haters of plus co-optation if this is worth pushing forward.

@SethTisue SethTisue removed this from the 2.12.2 milestone Feb 22, 2017
@dwijnand
Copy link
Member

I don't have the hate or bandwidth necessary atm.

Looked for someone on twitter https://twitter.com/dwijnand/status/834556490866389002

@nafg
Copy link
Contributor

nafg commented Aug 10, 2018

Instead of removing String#+, how about moving it to an implicit in Predef, that seems like it enables a more natural way of disabling it.

@som-snytt som-snytt removed WIP release-notes worth highlighting in next release notes labels Dec 7, 2018
@som-snytt som-snytt deleted the topic/language-future branch December 19, 2020 21:09
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

Successfully merging this pull request may close these issues.

7 participants