- Proposal: SE-NNNN
- Authors: Robert Widmann, Jaden Geller
- Review Manager: TBD
- Status: Awaiting review
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <time.h> | |
#import <os/lock.h> | |
#define ITERS 2000 | |
#define NSEC_PER_ITER(time) (((double)time * (double)NSEC_PER_SEC) / (double)ITERS) | |
#define TEST(body, name) do {\ | |
start = [NSDate date];\ | |
for (int i = 0; i < ITERS; i++) {\ |
Most of the manifesto is background and detailed definitions -- if you're confused or want details, read the manifesto!
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170213/032155.html
Note also that manifestos aren't complete proposals -- syntax and details may change!
One piece of background: inout
is kinda complicated because it can be used on computed properties -- foo(&val.x)
might be sugar for
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
const long count = 10000000; | |
const char *str1 = "hellohello"; //fits in a tagged pointer | |
const char *str2 = "hellohelQo"; //at this character count, can only fit in a tagged pointer by using <8 bits per character, which requires dropping less frequently used chars like 'Q' | |
const char *str3 = "Northern Sami"; //this string is encountered frequently enough that it's baked into a perfect hash table in CoreFoundation | |
const char *str4 = "hellohellü"; //this string can't be tagged *and* can't be stored using an ASCII backing store | |
NSDate *start = [NSDate date]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
final class SafeSyncQueue { | |
struct QueueIdentity { | |
let label: String | |
} | |
let queue: DispatchQueue |
Open/Close Xcode console:
cmd+shift+y
Jump to definition, but in the assistant editor:
cmd+opt+click
Open/close navigators pane:
cmd+0
Open/close inspectors pane:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SpinlockTestTests.swift | |
// SpinlockTestTests | |
// | |
// Created by Peter Steinberger on 04/10/2016. | |
// Copyright © 2016 PSPDFKit GmbH. All rights reserved. | |
// | |
import XCTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We can't use `Character` or `String` ranges directly because they aren't countable | |
// Create a countable range of ASCII values instead | |
let range = UInt8(ascii: "a")...UInt8(ascii: "z") // CountableClosedRange<UInt8> | |
// Convert ASCII codes into Character values | |
range.map { Character(UnicodeScalar($0)) } // Array<Character> | |
// → ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// clang -cc1 -analyzer-checker-help | |
// OVERVIEW: Clang Static Analyzer Checkers List | |
// USAGE: -analyzer-checker <CHECKER or PACKAGE,...> | |
// | |
// CHECKERS: | |
// alpha.core.BoolAssignment Warn about assigning non-{0,1} values to Boolean variables | |
// alpha.core.CallAndMessageUnInitRefArg | |
// Check for logical errors for function calls and Objective-C message expressions (e.g., uninitialized arguments, null function pointers, and pointer to undefined variables) | |
// alpha.core.CastSize Check when casting a malloc'ed type T, whether the size is a multiple of the size of T | |
// alpha.core.CastToStruct Check for cast from non-struct pointer to struct pointer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Paste me into a playground! | |
import Cocoa | |
//: # Basic Setup | |
protocol FancyProtocol { | |
associatedtype Thing | |
func holdPinkyUp(x: Thing) | |
} |