Skip to content

Instantly share code, notes, and snippets.

View drewcrawford's full-sized avatar

Drew Crawford drewcrawford

View GitHub Profile

Keybase proof

I hereby claim:

  • I am drewcrawford on github.
  • I am drewcrawford (https://keybase.io/drewcrawford) on keybase.
  • I have a public key ASDx8wkT-3SVLIASexYQZMlenrGMUa9iVWMXzWkj67ePWgo

To claim this, I am signing this object:

/usr/bin/clang++ -ldl -lpthread -lbsd -licui18n -licuuc /swift-dev/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/linux/x86_64/swift_begin.o /tmp/test2-9cbb9a.o -L /swift-dev/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift_static/linux --target=x86_64-unknown-linux-gnu -Xlinker -rpath -Xlinker /swift-dev/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift_static/linux -lswiftCore @/tmp/test2-49baa1.autolink /swift-dev/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/linux/x86_64/swift_end.o -o test2
swift: /swift-dev/swift/include/swift/AST/Decl.h:2160: swift::Accessibility swift::ValueDecl::getFormalAccess() const: Assertion `hasAccessibility() && "accessibility not computed yet"' failed.
0 swift 0x00000000033bff78 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x00000000033be716 llvm::sys::RunSignalHandlers() + 54
2 swift 0x00000000033c0b7a
3 libpthread.so.0 0x00007efc6ef0b8d0
4 libc.so.6 0x00007efc6d8f0067 gsignal + 55
5 libc.so.6 0x00007efc6d8f1448 abort + 328
6 libc.so.6 0x00007efc6d8e9266
7 libc.so.6 0x00007efc6d8e9312
8 swift 0x0000000000ce19e7

This, is actually the wrong conclusion. The entire purpose of the “inner class” is to provide value semantics while maintaining effeciency of implementation.

Is that an opinion? Or was there a meeting when the "entire purpose" of inner classes was established and I wasn't invited? Sure, they can be used for efficiency, but they can also be used for other purposes, including inner mutation.

Just for starters, Mike Ash seems to have uncovered that inner classes are used inside the standard library to provide destructors:

Destruction can be solved by using a class, which provides deinit. The pointer can be destroyed there. class doesn't have value semantics, but we can solve this by using class for the implementation of the struct, and exposing the struct as the external interface to the array.

So to say that the "entire purpose" of inner classes is efficiency is I think plainly false; they are used for many reasons. E

//: Playground - noun: a place where people can play
import Cocoa
var str = "Hello, playground"
import Foundation
class POSIXSocketNotificationHandle { }
protocol Nextable {
import Foundation
let notification = "MyNotification"
struct DontCopy {
var value = false
mutating func whatever(#callback:() -> ()) {
self.value = true
NSNotificationCenter.defaultCenter().addObserverForName(notification, object: nil, queue: nil) { (noti) -> Void in
/** An example statically-dispatched, trait-based recursive datastructure in Rust */
/**A master trait */
trait Link {
fn value(&self) -> i32;
fn next(&self) -> Option<&Link>;
fn sumOfValue(&self)->i32 {
let maybeNext = self.next();
match maybeNext {
Some(v) => {
//
// RLMRealmDescription.swift
// DCAKit
//
// Created by Drew Crawford on 1/24/15.
// Copyright (c) 2015 DrewCrawfordApps. All rights reserved.
//
import Foundation
import Realm
override func viewDidLoad() {
super.viewDidLoad()
var dict : [String: AnyObject] = [:]
dict[kSecClass] = kSecClassGenericPassword
dict[kSecMatchLimit] = kSecMatchLimitOne
dict[kSecReturnAttributes] = true
var rDict : Unmanaged<AnyObject>?
let status: OSStatus = SecItemCopyMatching(dict, &rDict)
if (rDict==nil) {
println("This behavior only in release mode.")
An alternative to semver
Major.minor.patch-tag
Major - For large, compatibility-breaking changes.
Minor - For features and fixes that are backwards compatible, as well as breaking changes that are "minor". This means breaking a small fraction of a large API, or breaking things that are simple to fix (like renaming a method, for example)
Patch - I only changed the bare minimum to fix an important bug or security issue