-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use Ammonite-style @ REPL prompt rather than scala>
#24307
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
base: main
Are you sure you want to change the base?
Conversation
|
@lihaoyi The PR extracting the repl has been merged. Can you please rebase now and fix the conflicts? |
|
@hamzaremmal Done |
| protected def promptStr = "scala" | ||
| private def prompt(using Context) = blue(s"\n$promptStr> ") | ||
| private def newLinePrompt(using Context) = blue(" | ") | ||
| protected def promptStr = "@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ is a cute symbol for ammonite (the name), but that cuteness does not apply for Scala in general. There's no precedent (that I know of) for this symbol being used as a general prompt anywhere.
I'm not against using a short prompt but then it should just be > like virtually all prompts in existence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A large motivation for the recent effort to renovate the REPL has been to merge all the useful parts of Ammonite into it: pretty-printed output, ctrl-c handling, library import, etc.. I expect Ammonite as a standalone project will go into maintenance mode soon after 3.8.0 is released.
Given that, @ looking like the Ammonite REPL is exactly what we want: for all intents and purposes, Ammonite going forward will be the default Scala REPL, and any association that people have with the @ symbol is exactly right.
We can come up with a new symbol, we can use > which is shared by a bunch of other REPLs. But @ is already widely known in the Scala community, has exactly the right associations (Scala REPL ++) and soon-to-be unambigious. So there's plenty of upsides of using this symbol and no long-term downsides
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that, @ looking like the Ammonite REPL is exactly what we want: for all intents and purposes, Ammonite going forward will be the default Scala REPL, and any association that people have with the @ symbol is exactly right.
...wait, slow down. While we very much appreciate all the improvements brought over from Ammonite REPL, Scala REPL remains its own thing. If anything, I think users may be confused with the @ being there. Some Ammonite REPL features won't be brought over (like the Ammonite style directives, for example).
I'm a fan of going with > myself, too.
We'll discuss how to move forward on Scala Core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of having long discussions, trying to figure out what would be best for users, maybe we could let them decide themselves? Personally, I've recently become a bit crazy about how one can make their life easier by customizing their shell prompt, but I wouldn't go too far for this moment. The prompt in the REPL could be configurable as a simple string (and maybe as a color) via a scala-cli flag (or potentially also via a directive to let people use a scala file as a template for REPL settings)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...we probably could make whatever we decide on customisable, yeah. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with > if that's what you all prefer, just let me know the decision and I'll update the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the arguments against @
OMG yes please!! Really happy to see this change included |
| private def newLinePrompt(using Context) = blue(" | ") | ||
| protected def promptStr = "@" | ||
| private def prompt(using Context) = purple(s"\n$promptStr ") | ||
| private def newLinePrompt(using Context) = purple(" ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my personal preference. If we were to have a > on the first line then maybe it's best to have one also in the lines after that to be able to easily keeps things aligned.
| private def newLinePrompt(using Context) = purple(" ") | |
| private def newLinePrompt(using Context) = purple(">") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with adding >s in subsequent lines is it makes copy paste harder. Without the > you just copy-paste-dedent, with the > you paste and the need to remove the > from each subsequent line, and also manually remove the space since it'll be one remaining space so a 2-space dedent doesnt work
|
@lihaoyi hey, so we've discussed this on today's Scala Core and the conclusions were as follows:
|
This has several advantages:
|s for multi-line input makes it much easier to copy-paste later: you can copy-paste-dedent it, rather than copy-paste-remove-vertical-pipes-dedent like you needed to do before@is already associated with Scala due to widespread usage of Ammonite, so people seeing this would immediately know it's a Scala REPLMost languages REPLs do not have the name of the language in the prompt (e.g. Python is
>>>, IPythonIn [N], Rubyirb(main):001:0>, Node>, etc.) so it's not a hard requirement to have the language namescalain the REPL prompt