[swift-evolution] Returning nothing

Daniel Steinberg daniel at dimsumthinking.com
Thu Jul 21 11:42:37 CDT 2016


This may be a silly question - given that one of Swift’s design principles is to be a language for new programmers and for APIs to read like English phrases, should we replace the typealias of Void for the return type () with Nothing.

So

f: ( input: Int) -> Void

becomes

f: ( input: Int) -> Nothing

Instead of saying “f takes an Int and returns a Void” I read this as “f takes an Int and returns nothing”.

I’ve been using f:(input: Int) -> () because it’s easier to explain than Void to non-experienced programmers. Experienced programmers have no problem with Void. But Void seems to be something we’re using just because we have for a while - like x++ and C-style for loops.

Best,

Daniel


More information about the swift-evolution mailing list