-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
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.
import dotty.tools.repl._
val repl = new ReplDriver(replArgs)
val predefCode =
"""
|def foo = 42
|import Int.MaxValue
|""".stripMargin
val state = repl.run(predefCode)(repl.initialState)
repl.runUntilQuit(state)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?
Metadata
Metadata
Assignees
Labels
No labels