- Proposal: SE-NNNN
- Author: Dan Appel
- Status: Awaiting review
- Review manager: TBD
This proposal introduces a new keyword that can be applied to enums which allows new cases to be introduced in extensions.
| //This is the url for my server. | |
| let client = Client(base: "www.myblog.com", method: .GET) | |
| //This is the api path. | |
| let api = client.endpoint("/api/v1", method: .GET) | |
| //This endpoint builds off of the api endpoint. | |
| let posts = api.endpoint("/posts", method: .GET) | |
| //This endpoint takes the response from that endpoint, uses it as a parameter for this endpoint |
| import Darwin.C | |
| import Venice | |
| struct SubProcess { | |
| let path: String | |
| let arguments: [String] | |
| func run(sync sync: Bool = true) -> Int? { |
| extension String { | |
| subscript(safe index: String.CharacterView.Index) -> Character? { | |
| guard index < endIndex else { return nil } | |
| return self[index] | |
| } | |
| } | |
| public final class Brainfuck { | |
| public enum Token { |
| // For evaluation purposes | |
| indirect enum Token: CustomStringConvertible { | |
| case Value(Int) | |
| case Add(Token, Token) | |
| case Subtract(Token, Token) | |
| case Multiply(Token, Token) | |
| case Divide(Token, Token) | |
| var description: String { | |
| switch self { |
| let length = 10 | |
| let ptr = UnsafeMutablePointer<UInt8>(allocatingCapacity: length) | |
| defer { ptr.deallocateCapacity(length) } | |
| for i in 0..<length { | |
| ptr.advanced(by: i).pointee = UInt8(i) | |
| } | |
| let buffer = UnsafeMutableBufferPointer(start: ptr, count: length) |
| protocol Event {} | |
| protocol ErasedListener { | |
| func dispatchIfMatches(event: Event) | |
| } | |
| struct Listener<T: Event>: ErasedListener { | |
| let dispatch: T -> Void | |
| func dispatchIfMatches(event: Event) { | |
| (event as? T).flatMap(dispatch) |
| enum Heap<Key: Comparable> { | |
| case empty(key: Key) | |
| indirect case halfFull(key: Key, left: Heap<Key>) | |
| indirect case full(key: Key, left: Heap<Key>, right: Heap<Key>) | |
| } | |
| extension Heap { | |
| var isFull: Bool { | |
| if case .full(key: _, left: _, right: _) = self { | |
| return true |
This proposal introduces a new keyword that can be applied to enums which allows new cases to be introduced in extensions.
| notifications: | |
| slack: zewo:VjyVCCQvTOw9yrbzQysZezD1 | |
| os: | |
| - linux | |
| - osx | |
| language: generic | |
| sudo: required | |
| dist: trusty | |
| osx_image: xcode8 | |
| install: |
| indirect enum Query { | |
| case equal(field: String, value: String) | |
| case notEqual(field: String, value: String) | |
| case not(query: Query) | |
| case or(first: Query, second: Query) | |
| case and(first: Query, second: Query) | |
| } | |
| func &&(lhs: Query, rhs: Query) -> Query { |