-
Notifications
You must be signed in to change notification settings - Fork 21
Improve REPL display #10024
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-10024?orig=1 |
@som-snytt said: scala> val (x, y) = (42, 17)
x: Int = 42
y: Int = 17 Customizing output is not amenable to piece-meal tweaks. |
Raphael Bosshard (esarbe) said: |
@dwijnand said: |
This and related REPL display issues might be good first issue if they were defined clearly on what are expected at the end. For example, this issue says "no output in the success case (as does the Python REPL)" as possible solution while #7960 says it would be better to include scala> var x = 5
var x: Int = 5 |
I agree with #7960. I think it's valuable to show the types, and it's valuable to show the computed value, too:
|
note that anyone doing nontrivial REPL work should target 2.13, since the REPL code changed around between 2.12 and 2.13 so merging changes forward is extra work we'd rather not do. |
Hi, I'm willing to pick this up, what exactly is the desired outcome? Do we want nothing in the case of a type definition, and to keep var and val definitions the same? Something like this: scala> case class Foo()
scala> val (x, y) = (42, 17)
x: Int = 42
y: Int = 17 |
awesome!
this is all open-ended and open to debate. these tickets were opened by interested individuals with opinions, they aren't the outcome of any process. if something is easy to tweak you might just go ahead and we can bikeshed it after, if something looks like bunch of work then you might check first whether people think it's a good idea re: "nothing in the case of a type definition", sounds good to me re: "keep var and val definitions the same", #7960 (which is now consolidated here) proposes adding |
Cool, I'll have a go at changing it to what I suggested above and come back here for feedback once it is ready or I reach a stumbling block. |
@df3n5 are you still planning on working on this? I was wondering if I could make an attempt. |
@psilospore No, I have no time for contributions at the moment. Good luck with it! |
also in this area: #11416 |
I'm currently working on this now, with the following choices:
scala> lazy val x = ""
lazy val x: String = <lazy>
scala> val (a, b) = (true, false)
val a: Boolean = true
val b: Boolean = false
scala> var mut = 0
var mut: Int = 0
scala> mut = 1
// mutated mut
scala> def foo = ""
def foo: String = <method>
scala> def foo[T: ClassTag, A: ClassTag](x: T): String = x.toString
def foo[T, A](x: T)(implicit evidence$1: ClassTag[T], evidence$2: ClassTag[A]): String = <method>
scala> def m(x: => Int): Int = macro ???
// defined term macro m(x: => Int): Int definitions scala> object A
// defined object A
scala> trait B
// defined trait B
scala> class C
// defined class C
scala> type D = Unit
// defined type alias D |
Improve REPL display - Fixes scala/bug#10024
The current REPL output for definitions is very confusing because it is almost, but not quite valid Scala and also inconsistent.
Some examples:
The Scala REPL's response should be more consistent reporting about definitions.
Possible solutions
The text was updated successfully, but these errors were encountered: