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

trunk regression: strange misbehaviors of :wrap in REPL #4896

Closed
scabug opened this issue Aug 9, 2011 · 3 comments
Closed

trunk regression: strange misbehaviors of :wrap in REPL #4896

scabug opened this issue Aug 9, 2011 · 3 comments
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Aug 9, 2011

Welcome to Scala version 2.10.0.r25463-b20110808085525 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).

scala> :power
** Power User mode enabled - BEEP BOOP SPIZ **
scala> :paste
// Entering paste mode (ctrl-D to finish)

  def time[T](fn: => T): (T, Double) = {
    val start = System.nanoTime
    (fn, (System.nanoTime - start) / 1.0E9)
  }
^D
// Exiting paste mode, now interpreting.

time: [T](fn: => T)(T, Double)

scala> :wrap time
Set wrapper to 'time'

scala> (1 to 1000000).sum

no error, no result, nothing. by contrast in 2.9.0.1 the same thing gives me a compile error:

<console>:6: error: type mismatch;
 found   : (java.lang.String, Double)
 required: String
  val $export: String = `time` {
                                                                                     ^

taking the hint and going back to trunk with a changed definition of "time":

Welcome to Scala version 2.10.0.r25463-b20110808085525 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).

scala> :paste
// Entering paste mode (ctrl-D to finish)

  def time[T](fn: => T): T = {
    val start = System.nanoTime
    val result = fn
    println((System.nanoTime - start) / 1.0E9)
    result
  }

^D
// Exiting paste mode, now interpreting.

time: [T](fn: => T)T

scala> :power
** Power User mode enabled - BEEP BOOP SPIZ **

scala> :wrap time
Set wrapper to 'time'

scala> time(3)
5.04E-4
4.35E-4
4.96E-4
4.97E-4
6.0E-6
0.001007
res0: Int = 3

now it's running my code over and over again. in 2.9 it works:

scala> time(3)
3.6E-5
res0: Int = 3
@scabug
Copy link
Author

scabug commented Aug 9, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4896?orig=1
Reporter: @SethTisue
See #7747

@scabug
Copy link
Author

scabug commented Feb 17, 2015

@som-snytt said:
The wrap command was removed from 2.10. The current idiom is:

scala> :pa
// Entering paste mode (ctrl-D to finish)

def timed(x: => String): String = {
  val start = System.nanoTime
  val res = x
  f"${((System.nanoTime - start) / 1.0E9).toInt}%d: $res"
}

// Exiting paste mode, now interpreting.

timed: (x: => String)String

scala> $intp.setExecutionWrapper($intp.global.exitingTyper($intp.symbolOfTerm("timed").fullName))

scala> 42
0: res1: Int = 42

scala> Thread sleep 5000L ; "Hello, timer."
5: res2: String = Hello, timer.

@scabug scabug closed this as completed Feb 17, 2015
@scabug
Copy link
Author

scabug commented Feb 17, 2015

@som-snytt said:
Relates to custom templating of embedded snippets.

@scabug scabug added this to the 2.10.5 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant