- Proposal: SE-NNNN
- Author: Paul Cantrell
- Status: Awaiting review
- Review manager: TBD
This proposal provides a robust, generalized mechanism for altering the behavior and API design of third-party libraries.
import Foundation | |
extension Array | |
{ | |
func median() -> Element | |
{ return self[count / 2] } | |
} | |
func time(name: String, iters: Int, closure: Void -> Void) -> NSTimeInterval | |
{ |
Siesta.enabledLogCategories = LogCategory.all | |
let service = Service(baseURL: myBaseURL) | |
service.configureTransformer("**") { (content: NSData, entity) -> NSXMLDocument? in | |
return try? NSXMLDocument(data: content, options: 0) | |
} | |
service.resource("foo.xml").load() |
This proposal provides a robust, generalized mechanism for altering the behavior and API design of third-party libraries.
import Foundation | |
// ——— The Setup ——— | |
protocol Foo | |
{ | |
associatedtype Bar | |
func modify(bar: Bar) -> Bar | |
} |
[Siesta:configuration] URL pattern ** compiles to regex ^https:\/\/api\.github\.com\/[^:?]*($|\?) | |
[Siesta:configuration] Added config 1 [**] | |
[Siesta:configuration] URL pattern /search/** compiles to regex ^https:\/\/api\.github\.com\/search\/[^:?]*($|\?) | |
[Siesta:configuration] Added config 2 [/search/**] | |
[Siesta:configuration] URL pattern /users/* compiles to regex ^https:\/\/api\.github\.com\/users\/[^/:?]*($|\?) | |
[Siesta:configuration] Added config 3 [/users/* : JSON → User] | |
[Siesta:configuration] URL pattern /users/*/repos compiles to regex ^https:\/\/api\.github\.com\/users\/[^/:?]*\/repos($|\?) | |
[Siesta:configuration] Added config 4 [/users/*/repos : JSON → Array<Repository>] | |
[Siesta:configuration] URL pattern /search/repositories compiles to regex ^https:\/\/api\.github\.com\/search\/repositories($|\?) | |
[Siesta:configuration] Added config 5 [/search/repositories : JSON → Array<Repository>] |
Siesta:configuration │ URL pattern ** compiles to regex ^https:\/\/api\.github\.com\/[^:?]*($|\?) | |
Siesta:configuration │ Added config 1 [**] | |
Siesta:configuration │ URL pattern /search/** compiles to regex ^https:\/\/api\.github\.com\/search\/[^:?]*($|\?) | |
Siesta:configuration │ Added config 2 [/search/**] | |
Siesta:configuration │ URL pattern /users/* compiles to regex ^https:\/\/api\.github\.com\/users\/[^/:?]*($|\?) | |
Siesta:configuration │ Added config 3 [/users/* : JSON → User] | |
Siesta:configuration │ URL pattern /users/*/repos compiles to regex ^https:\/\/api\.github\.com\/users\/[^/:?]*\/repos($|\?) | |
Siesta:configuration │ Added config 4 [/users/*/repos : JSON → Array<Repository>] | |
Siesta:configuration │ URL pattern /search/repositories compiles to regex ^https:\/\/api\.github\.com\/search\/repositories($|\?) | |
Siesta:configuration │ Added config 5 [/search/repositories : JSON → Array<Repository>] |
Do away with --enable-autopin
and --disable-autopin
. The only new package manager commands are pin
and unpin
.
There are two pinfiles: a private one and a shared one. The shared one is adjacent to Package.swift, as in the existing proposal. The private one is stored in some quasi-hidden location not likely to be checked in, e.g. a dotfile, and is an implementation detail.
swift package pin foo 1.2.3
writes a dependency version to the shared pinfile; swift package unpin foo
removes it from the shared one. Running swift package pin foo
with no version number copies the entry from the private pinfile to the shared one, with its current version.
swift package update
only searches for new versions of packages listed in the private pinfile; --repin
is required to update packages in the shared one.
In the shared pinfile, there is a boolean setting that determines whether newly downloaded dependencies are added to the shared pinfile. Both swift package pin --all
and swift package pin --new
se
alias {stash,branch}=git | |
touch branch stash | |
stash add stash branch | |
branch commit -m stash > branch | |
branch stash save branch | |
stash stash save stash > stash | |
branch stash save stash | |
branch branch stash | |
stash stash branch branch | |
branch checkout -- stash branch |
Suppose we have a country of 10 mutually hostile religious factions. Each is around 10% of the population; the largest group is the Fooists, who are 12%.
Suppose each relgious faction nominates a candidate whose platform is “outlaw all other religions except mine.”
Suppose that there is also an 11th candidate, the tolerant one, whose platform is “allow freedom of religion.”
The country is so balkanized that every citizen’s preferences are as follows:
protocol A { | |
func foo() | |
} | |
extension A { | |
func foo() { print("A foo") } | |
func bar() { print("A bar") } | |
} | |
protocol B: A { | |
func bar() | |
} |