--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
a simple one-liner that disables it
--
--
One big caveat here is that Scala hardcodes things like (Int + String
=> Int) into the scala.Int type, so there is no way to disable that.
https://github.com/scala/scala/blob/master/src/library/scala/Int.scala#L45
I only mention this because I am overwhelmingly affected by this
problem with number types like Int and Double.
And AnyToStringAdd can be disabled with the Predef import that Som showed.
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- Erik
> String + is used by most Scala files out there.+1. I think basically every project i've ever written will break if we take it out suddenly; even with string interpolation, I often use string addition purely out of habit.On the other hand, that may be an argument that we should deprecate it now so people slowly stop using it. If all my use sites were covered in deprecation-warnings/-highlights, I probably would be annoyed into using it much less.
> Until there is a major version bump this is a clear case of a lint tool, IMO.Problem is, any2stringadd is not just a "gotcha" that causes bugs. It actually pollutes the global namespace and makes it annoying to use + as an extension method in any of your libraries because of ambiguous implicits. Lint tools are normally meant for silent-killers, whereas this (noisily causing compilation failures) is something a lint tool won't help with.
I believe for precisely that reason we need an all-or-nothing solution. It would not do to have one part of the Scala community clean their code of String-+ and start to add + methods (extension or otherwise) to their libraries, only for the other part that has not upgraded yet to fall in a hole.
Cheers
- Martin
Speaking as a scala novice, I would very much appreciate the compiler warning me and telling me to "fix" my code now, or at least warn me to stop writing new code depending on any2stringadd.
I think the only argument preventing us to remove AnyToStringAdd altogether is existing Scala code. Removing it now would simply break too much. I believe there will be some point in the future where will contemplate a major shift in Scala that would be supported by a migration tool based on automated source code rewriting.
In such a situation would be easy to get rid of things like AnyToStringAdd or procedure syntax, or any of a number of other things.Cheers- Martin
On Wednesday, January 29, 2014 12:40:14 PM UTC, martin wrote:I think the only argument preventing us to remove AnyToStringAdd altogether is existing Scala code. Removing it now would simply break too much. I believe there will be some point in the future where will contemplate a major shift in Scala that would be supported by a migration tool based on automated source code rewriting.Will this migration tool be a top priority for 2.12 then? And can we least be guaranteed a compiler opt out parameter in 2.11?
In such a situation would be easy to get rid of things like AnyToStringAdd or procedure syntax, or any of a number of other things.Cheers- MartinI don't know if others feel the same but for me AnyToStringAdd is not just one among many wishes but is uniquely bad. Over time I've been persuaded by your arguments against enums, although if we're not going to do them right lets not do them at all. Maybe getting rid of enums is actually a language improvement. AnyToStringAdd is a step backwards from Pascal, C, C++, C# and others. Combined with type inference it is actually step backwards form Java as well. Although not as bad I would argue that Scala's over enthusiastic type inference, Any, AnyRef, AnyVal etc is also a step backwards from Pascal, C, C++, C# and Java. Primum non nocere. This is 2014, really I don't think a String should any longer be allowed to pass as strongly typed.
--
I can pretty much guarantee that a solution will come in due time. But I am also strongly proposed to any half-baked, temporary measures until then. These are well intended, to be sure, but in the end only lead to needless complexity. Give it time, and we will fix it for good :-)
Regarding the arguments against deprecation -- maybe we need a new class of warning for things that will break further into the future than "deprecated" usually indicates. This way it won't cause people to turn off warnings.
Also I guess it's obvious but now that we have string interpolation the case for StringAdd is even weaker than before.
I can pretty much guarantee that a solution will come in due time. But I am also strongly proposed to any half-baked, temporary measures until then. These are well intended, to be sure, but in the end only lead to needless complexity. Give it time, and we will fix it for good :-)
Thanks, nice to hear!
--
Regarding the arguments against deprecation -- maybe we need a new class of warning for things that will break further into the future than "deprecated" usually indicates. This way it won't cause people to turn off warnings.
Also I guess it's obvious but now that we have string interpolation the case for StringAdd is even weaker than before.
--
"Vals in traits" have a valid usage; when you are declaring a super-high level cakey abstraction over a bunch of things, and you want certain members to end up with a fixed path, permitting imports and .type access.Arguably still not worth it.
... it would be useful to have an annotation that indicates that a trait should be compilable to a Java interface. (Which is what I assume was Simon's intent.)
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.