<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">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:<div class=""><br class=""></div><div class=""><ul class="MailOutline"><li class="">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.</li><li class="">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.</li></ul><div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="" style="font-family: LucidaGrande; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><font color="#424242" class="" style="font-family: 'Lucida Grande'; font-size: x-small;">Kate Stone</font><span class="" style="font-family: 'Lucida Grande'; font-size: x-small;"> </span><font color="#009193" class="" style="font-family: 'Lucida Grande'; font-size: x-small;"><a href="mailto:k8stone@apple.com" class="">k8stone@apple.com</a></font></div><div class="" style="font-family: Times; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><font face="Lucida Grande" size="1" class=""><font color="#009193" class=""></font> Xcode <font color="#424242" class="">Low Level Tools</font></font></div></div></div></div></div></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Dec 22, 2015, at 1:38 PM, Jonas Fredriksson via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">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)? <br class="">I am looking for something similar like %run in ipython. <br class=""></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=9Y0WV-2FgqTGrqbN7qMHvjRxXmfmwtkNQjc5HmD-2BCpqdd1oAwVc5rzRRHZxS3UEGwZTaM-2FZPNwCBYU2fxnELt0Qt9YbGd5uwDbBHUVXzWqYX1CIXopKXP0S81p-2FHhJQMrzDBPFpX2T2JGG-2F8pTJtf2Q9-2B0sZXwB2fHebWBj-2Fk30hHghqIswPR1u3kwPiIKZeKLRq931PXxYS5yQ9ccpatYkYUXSG-2BH3EUWPi01frkKLeA-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></div></body></html>