- Proposal: SE-NNNN
- Authors: Karl Wagner
- Review Manager: TBD
- Status: Awaiting review
During the review process, add the following fields as needed:
- Decision Notes: Rationale, Additional Commentary
import Foundation | |
/// This isn't safe to use before Swift gets ABI stability, because generic classes | |
/// could change their names. Also, be sure to register bridges with the Obj-C runtime | |
/// if using to decode during iOS state restoration. | |
/// | |
class CodableBridge<Wrapped: Codable>: NSObject, NSSecureCoding { | |
let value: Wrapped | |
init(_ value: Wrapped) { self.value = value } |
struct VirtualKeyPath<Root, Value> { | |
private let block: (Root) -> Value | |
init(block: @escaping (Root) -> Value) { self.block = block } | |
} | |
// Evaluation | |
extension VirtualKeyPath { | |
func evaluate(on: Root) -> Value { return block(on) } |
extension Collection { | |
/// Repeats the collection _itself_ N times. | |
/// | |
/// ``` | |
/// > [1, 2, 3].repeated(3).forEach { print($0) } | |
/// [1, 2, 3] | |
/// [1, 2, 3] | |
/// [1, 2, 3] |
import Dispatch | |
// Import C11 for atomic_flag | |
// FIXME: SWIFT(canImport) | |
//#if canImport(Glibc) | |
// import Glibc.stdatomic | |
//#elseif canImport(Darwin) | |
import Darwin.C.stdatomic | |
//#endif |
During the review process, add the following fields as needed:
The compiler would statically optimise a function with particular values, and generate an entry point which checks for the values and runs the optimised implementations.
@_specialize(value: 42)
// Some function on our hot path
func someFunction(value: Int) -> Result? {
if value == 42 {
// magic value. Do some special processing.
The standard library lacks equivalents to the floor()
and ceil()
functions found in the standard libraries of most other languages. Currently, we need to import Darwin
or Glibc
in order to access the C standard library versions.
#!/usr/bin/env python | |
import argparse | |
import sys | |
import gzip | |
import urllib | |
import urlparse | |
import posixpath | |
import cStringIO | |
import os |