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

REPL output should be less confusing #10024

Open
scabug opened this Issue Nov 3, 2016 · 13 comments

Comments

Projects
None yet
5 participants
@scabug
Copy link

scabug commented Nov 3, 2016

The current REPL output for definitions is very confusing because it is almost, but not quite valid Scala and also inconsistent.

Some examples:

scala> case class Foo()
defined class Foo
scala> trait Bar
defined trait Bar
scala> type Qux = Nothing
defined type alias Qux
scala> val a = 1
a: Int = 1
scala> var b = 1
b: Int = 1

The Scala REPL's response should be more consistent reporting about definitions.
Possible solutions

  • no output in the success case (as does the Python REPL)
  • display the type definition (as it is currently the case but without "defined" )
  • display the type definition as valid Scala
  • ...
@scabug

This comment has been minimized.

Copy link
Author

scabug commented Nov 3, 2016

Imported From: https://issues.scala-lang.org/browse/SI-10024?orig=1
Reporter: Raphael Bosshard (esarbe)
Blocks #7960, #10023

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Nov 3, 2016

@som-snytt said:
There's a PR underway for pretty-printing. Also consider output such as

scala> val (x, y) = (42, 17)
x: Int = 42
y: Int = 17

Customizing output is not amenable to piece-meal tweaks.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Nov 3, 2016

Raphael Bosshard (esarbe) said:
What's the pretty-printing PR's number?

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Nov 3, 2016

@dwijnand said:
[~esarbe]: scala/scala#5222

@scabug scabug added this to the Backlog milestone Apr 7, 2017

@eed3si9n

This comment has been minimized.

Copy link
Member

eed3si9n commented Feb 6, 2018

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 val or val:

scala> var x = 5
var x: Int = 5
@SethTisue

This comment has been minimized.

Copy link
Member

SethTisue commented Feb 6, 2018

no output in the success case (as does the Python REPL)

I agree with #7960. I think it's valuable to show the types, and it's valuable to show the computed value, too:

scala> val x = 2 + 2
x: Int = 4
@SethTisue

This comment has been minimized.

Copy link
Member

SethTisue commented Feb 6, 2018

closed #7960 and #10023, consolidating here.

@SethTisue

This comment has been minimized.

Copy link
Member

SethTisue commented Feb 6, 2018

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.

@df3n5

This comment has been minimized.

Copy link

df3n5 commented Mar 7, 2018

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
@SethTisue

This comment has been minimized.

Copy link
Member

SethTisue commented Mar 7, 2018

I'm willing to pick this up

awesome!

what exactly is the desired outcome

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 val or var to bring it closer to being legal Scala that's printed

@df3n5

This comment has been minimized.

Copy link

df3n5 commented Mar 7, 2018

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.

@psilospore

This comment has been minimized.

Copy link

psilospore commented Oct 7, 2018

@df3n5 are you still planning on working on this? I was wondering if I could make an attempt.

@df3n5

This comment has been minimized.

Copy link

df3n5 commented Oct 7, 2018

@psilospore No, I have no time for contributions at the moment. Good luck with it!

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