#swift

25 links · 2014–2023

There are property implementation patterns that come up repeatedly. Rather than hardcode a fixed set of patterns into the compiler, we should provide a general “property behavior” mechanism to allow these patterns to be defined as libraries.

A var or let declaration can specify its behavior in parens after the keyword:

var (lazy) foo = 1738

“By making the view controller conform to the protocols for the ValidatesUsername and ValidatesPassword mixins, it automatically pulls the isUsernameValid() and isPasswordValid() methods into the code. […] This is a nice trick to keep your view controllers clean without having to use extra helper objects.”

“The final keyword […] indicates that the declaration cannot be overridden. This allows the compiler to safely elide dynamic dispatch indirection. […] [T]he private keyword […] allows […] to infer the final keyword automatically […] Whole Module Optimization […] allows to […] infer final on declarations with internal […]”

“Suppose your application revolves around file handles, and you want to be sure that you never try to perform any write operations on a file handle that’s open for reading.”

“attempt to gather the Swift features that are still in flux and likely to change”

programming language designed by Apple to replace Objective-C


links collected by
Maciej Konieczny

latest · tags · feed