Any swift option that will let you stay in REPL after file has been executed?

If I just start the swift REPL with a command like swift myscript.swift, then I will be returned to the shell once the myscript.swift has executed. Instead, I would like to remain in the REPL to work with the data and functions that my script has generated. Is that possible?

It would also be very useful if the script (myscript.swift) could have access to additional arguments, in case I run it with a command like swift myscript.swift arg1 arg2.

The latter does work, using CommandLine.arguments. The former is an interesting idea; today the script interpreter mode uses a different, faster execution path than what the REPL does (executing everything at once rather than line-by-line, and not saving the results). But it certainly seems like something useful. Can you file a feature request at

Thanks for your reply. I shall file a feature request.
Request here: [SR-8793] Access to file data and functions in REPL · Issue #4487 · apple/llvm-project · GitHub

Note that you can start the REPL at any time from the debugger with the repl command. You could try compiling your program with debug info, setting a breakpoint at the end, and entering the REPL from there.