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

Too long NumericRange don't behave consistently #5622

Closed
scabug opened this issue Mar 27, 2012 · 3 comments
Closed

Too long NumericRange don't behave consistently #5622

scabug opened this issue Mar 27, 2012 · 3 comments
Assignees

Comments

@scabug
Copy link

scabug commented Mar 27, 2012

A NumericRange with more than Int.MaxValue elements can be created, but is almost useless since we cannot use it:

=== Reproduce bug ===

scala> object Test {val x = 1L to 1000000000000L}
defined module Test

scala> Test.x take 10

=== Propositions ===

  • Reject such NumericRange at their initialization.
    PRO It seems that it suffices to remove the lazy evaluation of numRangeElements to do it.
    CON We need to evaluate it at initialization, it's a (small?) performance penalty
  • Try to workaround the issue: many methods can be updated to avoid call to length.
    CON painful patch, implementation will not be harmonized with Range
    CON some methods cannot be rewritten (length ofr example)
    PRO We can use "long" NumericRange for some operations
  • Don't do anything: keep it as a feature
@scabug
Copy link
Author

scabug commented Mar 27, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5622?orig=1
Reporter: Nicolas Biri (berewt)
Affected Versions: 2.9.1, 2.10.0-M2

@scabug
Copy link
Author

scabug commented May 8, 2012

@axel22 said:
This range is rejected at its initialization point. It's just that the object Test is initialized lazily - the first time it's accessed.
Try this:

scala> object Test { println("hello :-)") }
defined module Test

scala> Test
hello :-)
res0: Test.type = Test$@6eb92a0e

@scabug scabug closed this as completed May 8, 2012
@scabug
Copy link
Author

scabug commented May 10, 2012

Nicolas Biri (berewt) said:
Oups, I haven't test the creation of the range directly, sorry for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants