Skip to content

Instantly share code, notes, and snippets.

View AlexanderNey's full-sized avatar

Alexander Ney AlexanderNey

  • Atlassian
  • Sydney, Australia
View GitHub Profile
@nicklockwood
nicklockwood / gist:21495c2015fd2dda56cf
Last active August 13, 2020 13:57
Thoughts on Swift 2 Errors

Thoughts on Swift 2 Errors

When Swift was first announced, I was gratified to see that one of the (few) philosophies that it shared with Objective-C was that exceptions should not be used for control flow, only for highlighting fatal programming errors at development time.

So it came as a surprise to me when Swift 2 brought (What appeared to be) traditional exception handling to the language.

Similarly surprised were the functional Swift programmers, who had put their faith in the Haskell-style approach to error handling, where every function returns an enum (or monad, if you like) containing either a valid result or an error. This seemed like a natural fit for Swift, so why did Apple instead opt for a solution originally designed for clumsy imperative languages?

I'm going to cover three things in this post:

@florianbuerger
florianbuerger / image.py
Last active December 11, 2015 22:49 — forked from phughes/image.py
import os.path as path
import string
import argparse
import glob
import re
def basename(filename):
base = filename
if filename.find('@2x') > 0:
base = filename[:filename.find('@2x')]
@nielsbot
nielsbot / UIImage+JPEG2000.h
Created February 19, 2012 00:43
Decoding JPEG 2000 files to UIImage
#import <Foundation/Foundation.h>
extern UIImage * UIImageWithJPEG2000Data( NSData * data ) ;