REPL predef functionality #17695
Replies: 3 comments
-
A Scala 2 has
and
It's worth distinguishing "predef" as "available definitions" from "initialization" as "things to evaluate on startup". I don't know if there is a roadmap or policy for contributions, but there is also a useful distinction between "basic REPL that demonstrates language features" and "extended tool for prototyping or scripting". Ammonite and scala-cli serve the latter purpose. |
Beta Was this translation helpful? Give feedback.
-
Ok, thanks for the feedback! Your answer sounds like predef is probably not something we want to have in the standard scala3 repl - do I interpret that correctly? In that case we can close the ticket. |
Beta Was this translation helpful? Give feedback.
-
To clarify, I intended only to clarify terms. It seems to me a useful feature in some form.
|
Beta Was this translation helpful? Give feedback.
-
The REPL currently doesn't have predef functionality, i.e. the ability to execute some code automatically on startup. I didn't find this being discussed or worked on. I happen to have that need, and this was asked on Discord in the past.
The below suits my needs, but I thought it might make sense to bring this into the standard repl, e.g. as a parameter, since it's a fairly common functionality of a repl.
For reference: Ammonite has are three distinct ways to pass predef code:
~/.ammonite/predef.sc
- runs every time this user starts ammoniteamm --predef-code 'def foo = 42'
amm --predef someFile.sc
Would you be open to a contribution that adds a predef functionality to the REPL, or is the intention to keep the repl as small as possible?
Beta Was this translation helpful? Give feedback.
All reactions