Add TextOutputStream to FileDescriptor?
- Dominant language
- Swift
- Stars
- 1.4k
- Forks
- 154
- PR merge metrics
- No merged PRs in 30d
Description
Would it make sense to add `TextOutputStream` conformance to `FileDescriptor` to support writing something like this:
```swift
print("An error occurred", to: FileDescriptor.standardError)
```
Hmm, I tried doing this:
```swift
print("File exists.", to: &FileDescriptor.standardError) // Cannot pass immutable value as inout argument: 'standardError' is a get-only property
extension
FileDescriptor : TextOutputStream
{
public mutating func write(_ inString: String) {
_ = try? FileDescriptor.standardError.writeAll(inString.utf8)
}
}
```
Perhaps those would be better as `public static` members?
Contributor guide
Research direction
Start with the FileDescriptor API and its standardError member, then review Swift's TextOutputStream requirements. Resolve whether the proposed print(to:) usage and static-member alternative are appropriate; done means an agreed API design with its behavior verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100