Can you save your Clojure REPL's state (or, effectivelly, can you program complex programs using REPL?)
most people work with the repl through an editor such ad Eclipse/Emacs/vim and that editor has the ability to save the repl, though without some diligence on the developers part this will likely be an incomplete record of what happened. Some of the state of the repl may have come from loading files etc which will be in a different state.
So the short answer is typically not.
Starting Swift REPL for iOS vs OSX
One way to do this is to create an iOS/OS X project and set a break point to interrupt the flow. Then, enter repl
into the lldb console and enjoy.
For more on this one, watch WWDC 2014 session 409 - Introduction to LLDB and the Swift REPL.
How can I mimic load-file behavior with use ?
special forms like use
are well... special. you can't write functions that 'use' namespaces into the callers ns. But a simple macro can save you!
I did this in a project back before I had leiningen to load my repl properly
(defmacro load-all []
'(use
:reload-all
'com.cryptovide.modmath
'com.cryptovide.combine
'com.cryptovide.split
'com.cryptovide.encrypt
'com.cryptovide.misc
'com.cryptovide.decrypt
'com.cryptovide.modmathTest
'com.cryptovide.combineTest
'com.cryptovide.splitTest
'com.cryptovide.encryptTest
'com.cryptovide.miscTest
'com.cryptovide.decryptTest
'com.cryptovide.testlib
'com.cryptovide.gui
'com.cryptovide.checksum
'com.cryptovide.log))
When you call this, the reader runs the use
es from the namespace that you call it in (for example it will use
them into the repl's current ns
How can I mimic load-file behavior with use ?
special forms like use
are well... special. you can't write functions that 'use' namespaces into the callers ns. But a simple macro can save you!
I did this in a project back before I had leiningen to load my repl properly
(defmacro load-all []
'(use
:reload-all
'com.cryptovide.modmath
'com.cryptovide.combine
'com.cryptovide.split
'com.cryptovide.encrypt
'com.cryptovide.misc
'com.cryptovide.decrypt
'com.cryptovide.modmathTest
'com.cryptovide.combineTest
'com.cryptovide.splitTest
'com.cryptovide.encryptTest
'com.cryptovide.miscTest
'com.cryptovide.decryptTest
'com.cryptovide.testlib
'com.cryptovide.gui
'com.cryptovide.checksum
'com.cryptovide.log))
When you call this, the reader runs the use
es from the namespace that you call it in (for example it will use
them into the repl's current ns
Swift compiler: Printing the AST of a Swift file with 3rd party imports
Looks like an alternative to printing the AST with the Swift compiler is to use SourceKit.
There's a CLI tool called SourceKitten which allows you to parse the structure of a Swift source file into JSON format, without needing to handle imports of 3rd party frameworks and other source files.
Input from the keyboard in command line application
I managed to figure it out without dropping down in to C:
My solution is as follows:
func input() -> String {
var keyboard = NSFileHandle.fileHandleWithStandardInput()
var inputData = keyboard.availableData
return NSString(data: inputData, encoding:NSUTF8StringEncoding)!
}
More recent versions of Xcode need an explicit typecast (works in Xcode 6.4):
func input() -> String {
var keyboard = NSFileHandle.fileHandleWithStandardInput()
var inputData = keyboard.availableData
return NSString(data: inputData, encoding:NSUTF8StringEncoding)! as String
}
Related Topics
How to Create a Hotspot Network in iOS App Using Swift
Hmac Sha512 Using Commoncrypto in Swift 3.1
Core Image Filter Cisourceovercompositing Not Appearing as Expected with Alpha Overlay
Apple-App-Site-Association Is Not Working
How to Import Googleanalytics Header into a Library Framework
Set Custom Uiview Frame in Uiviewrepresentable Swiftui
Ios: Ambiguous Use of Init(Cgimage)
Menuapp in Swift 4 to Run on Login for High Sierra
When to Call Activatesession() on Wcsession Object
How to Get Walking and Running Distance Using Healthkit in Swift
Swiftui Classes That Conforms Observableobject Should Be Singleton
How to Compare Cgpoints in Swift
Calling Stop() on Avaudioplayernode After Finished Playing Causes Crash
Computed (Nsobject) Properties in Swiftui Don't Update The View
How to Convert Bytes to Nsstring After Aes Cryptoswift Cipher