On 24 Nov 2015, at 12:53 PM, Perry E. Metzger <
pe...@piermont.com> wrote:
> Sorry to be asking so many basic questions. :(
Please, don't feel bad for asking questions! You should feel absolutely welcome to. :)
> 1) Are there any names in the standard library for standard output and
> standard error? (I'd ask about stdin but there doesn't seem to be any
> standard way of reading from anything other than readLine?)
>
> 1.5) For that matter, is there any way to do things like opening and
> closing files without calling in to the Objective C Foundation?
The Darwin module is an interface to the C standard library, and exports `stdin`, `stderr` and `stdout` as `UnsafeMutablePointer<FILE>` (a.k.a. `FILE *`):
% swift
Welcome to Apple Swift version 2.1 (700.1.101.6 700.1.76). Type :help for assistance.
1> import Darwin
2> stdin
$R0: UnsafeMutablePointer<FILE> = {
_rawValue = 0x00007fff77c0c2b0 __sF
}
3> stdout
$R1: UnsafeMutablePointer<FILE> = {
_rawValue = 0x00007fff77c0c348 __sF + 152
}
4> stderr
$R2: UnsafeMutablePointer<FILE> = {
_rawValue = 0x00007fff77c0c3e0 __sF + 304
}
But there's no standard way, insofar as there's nothing in the standard library. The options as I understand them are to use Foundation, or standard C functions.
–Adam