[swift-evolution] Addition of a standardError OutputStream

Erica Sadun erica at ericasadun.com
Fri Jul 8 18:33:44 CDT 2016


Right now it's more like "foo".write(to: &stream) but I agree that having to implement
a custom stream is kind of irritating for stderr and stdout.

import Cocoa

var str = "Hello, playground"

struct StderrStream: OutputStream {
    static var shared = StderrStream()
    func write(_ string: String) { fputs(string, stderr) }
}

str.write(to: &StderrStream.shared)

-- E


> On Jul 8, 2016, at 4:41 PM, Saagar Jha via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Currently, it’s rather annoying to print to standard error, requiring either something low-level like fputs. I was wondering if a standardError OutputStream could be added to the standard library, so we could write something like print(“foo”, &standardError).
> 
> -- 
> -Saagar Jha
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160708/9ce7a70c/attachment-0001.html>


More information about the swift-evolution mailing list