[swift-corelibs-dev] Proposal: Make NSTask's standardInput/standardOutput/standardError properties type-safe

Dan Stenmark daniel.j.stenmark at gmail.com
Thu Dec 17 13:34:18 CST 2015


This is my first proposal to swift-corelibs, so I’m not sure how much flexibility we have in terms of deviating from the darwin’s original Foundation definitions.  That said, it’s always seemed a little screwy to me that NSTask's standardInput/standardOutput/standardError properties sacrifice any semblance of compile-time type safety by accepting id/AnyObject (which, at run time, must be either NSPipe or NSFileHandle, else it blows up).  If allowed, I’d like to take the opportunity to modernize this in the open source version of Foundation.

public class NSTask : NSObject {
    
...    

    public enum IOType {
        
        case FileHandle(NSFileHandle)
        case Pipe(NSPipe)
    }
    
    public var standardInput: NSTask.IOType?
    public var standardOutput: NSTask.IOType?
    public var standardError: NSTask.IOType?

...

   
}

Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20151217/92d4ebde/attachment.html>


More information about the swift-corelibs-dev mailing list