Rotated Windows

I’d forgotten about this until I stumbled across a reference to it again recently. This was a little hack I worked on back in 2004, with Mac OS X Tiger (10.4).  Yes, kids, macOS was called Mac OS X back in ye Olden Times. Wow, Slashdot looked even uglier than I remember, back then.  Though … Read more

Undocumented Swift conditional compilation macros

swift/lib/Basic/LangOptions.cpp has most of the conditional compilation macros (called “Language Options” in the compiler internally).  Notably the swift() version macro is absent, and doesn’t seem to be defined anywhere… At time of writing the two undocumented additions, to the os(), arch(), and swift() set, are _endian() and _runtime(). I have no idea if they’re useful … Read more

#if DEBUG in Swift

Sigh. The Swift team give an impeccable impression of a group of people who’ve never actually tried to use Swift. An incredibly basic compiler task is to provide code a way to distinguish between debug & release builds, in order that it can behave accordingly (e.g. change the default logging verbosity, change asserts from fatal to … Read more

Stupid Swift error message #a bajillion and one

Input code: let componentsOfPotentialInterest = [Calendar.Component: ((Int) -> String)]( .day: { String($0 + 1) }, ) Push button.  Expect results (or at least bacon).  Get: Foo.swift:76:21: error: expected ‘,’ separator .day: { String($0 + 1) }, ^ , Foo.swift:76:21: error: expected expression in list of expressions .day: { String($0 + 1) }, ^ Foo.swift:76:21: error: … Read more

Flinging poo in Swift

Thanks to one of the genuine upsides of Swift, full Unicode support in the compiler itself, you can do: enum EmojiErrors: Error { case 💩 } let 💩 = EmojiErrors.💩 Finally you can express yourself honestly within your program: throw(💩) Or, if you prefer to be polite & British about it: func flinging<E: Error>(_ error: … Read more