Closed scabug closed 8 years ago
Imported From: https://issues.scala-lang.org/browse/SI-9656?orig=1 Reporter: Rob Norris (rnorris)
Rob Norris (rnorris) said: Also ridiculous: JIRA. No idea how to make my example show up in monospace.
@som-snytt said: The [scaladoc](http://www.scala-lang.org/api/2.11.7/index.html#scala.collection.immutable.Range@toString():String) is also funky.
It's not like the max value for printing is some arbitrary value.
private[immutable] val MAX_PRINT = 512 // some arbitrary value
The question is why does it use JAVA_CONVENTIONS.
You don't get any help from stringOf, where you can specify max, because
// When doing our own iteration is dangerous
def useOwnToString(x: Any) = x match {
// Range/NumericRange have a custom toString to avoid walking a gazillion elements
case _: Range | _: NumericRange[_] => true
The irony is that the REPL thinks a million elements is also too much, and inserts its own ellipsis.
scala> 1123 to 273645 by 261
res1: scala.collection.immutable.Range = Range(1123, 1384, [snip] 29833, 30094, 3...
If only there were a type class for this sort of thing... Call it the TrailingEllipsis type class...
Stephen Robinson-Burns (stevorobs3) said: I have added a pull request here .
@som-snytt said: Or maybe here: https://github.com/scala/scala/pull/5001
@SethTisue said: 5001: A Range Odyssey
Stephen Robinson-Burns (stevorobs3) said: Yes - thanks that's the right link. The branch is now building and has passed all the tests - not sure what the next stage is for getting it into a release
@som-snytt said: I think this issue is blocked until the Scala team is Home on the Range again. Really, the ticket is at least two or three puns away from consideration.
@szeiger said: Fixed in https://github.com/scala/scala/pull/5175
The toString on Range prints out all the elements, unless there are too many in which case it gets truncated and you can't determine what the max value is. And you have to do the math in your head if you want to know what the step is.
I suggest that something like Range(start, stop, step) might be more useful.