Dump history from the swift repl

Hi all,

I'm looking to save my repl session to a swift file, similar to ipython's %save myfile.py command. It looks like there is a command to do this:

:session save

Unfortunately, the contents of the dumped file is always empty (using swiftlang-6.2.0.19.9). Does anyone have the trick to populate it?

Thanks,
Lou

Hi,

In order to use the session save command in lldb, you need to enable the session “recording”:

  1> :set show interpreter.save-transcript 
interpreter.save-transcript (boolean) = false
  1> :set set interpreter.save-transcript true 
  1> :set show interpreter.save-transcript 
interpreter.save-transcript (boolean) = true

However, after running the command, it does generate the transcript file but only contains the lldb commands run (the ones starting with :), not the expressions that were evaluated in the REPL.

My guess is that the session transcript functionality hooks into lldb’s command interpreter whereas the swift real uses the expression evaluator APIs directly, bypassing the transcript save functionality. If you’d like to see this feature working please file an issue.

Ismail.

1 Like