import module into REPL

if I have a source code in file A, how can I compile it as an module and
import it to REPL (I am using swift on ubuntu)?
I am looking for something similar like %run in ipython.

There isn’t a mechanism for importing definitions from source as a module in the REPL currently, though it would make a perfectly reasonable enhancement and might constitute an interesting project for someone motivated to do so. Using the existing REPL you have two options:

Compile the source as a library with public entry points and invoke the REPL with -l<library-path> to make it available during a REPL session.
Copy and paste a source file into the REPL. The input system automatically recognizes when code is being pasted and disables automatic formatting and completion detection. Pressing return after the paste operation will parse the entire buffer as one compilation unit, making all of the relevant declarations available for subsequent use.

Kate Stone k8stone@apple.com <mailto:k8stone@apple.com>
 Xcode Low Level Tools

···

On Dec 22, 2015, at 1:38 PM, Jonas Fredriksson via swift-users <swift-users@swift.org> wrote:

if I have a source code in file A, how can I compile it as an module and import it to REPL (I am using swift on ubuntu)?
I am looking for something similar like %run in ipython.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users