Returning nothing

(James Froggatt) #1

I always thought Empty would be a good name for it. Matches ‘empty tuple', and accurately describes instances of the type.

Nothing seems to imply non-existence, which seems more in the realm of Never. Empty implies instances can exist, they just can't be meaningfully differentiated.

------------ Begin Message ------------
Group: gmane.comp.lang.swift.evolution
MsgID: <>

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.


f: ( input: Int) -> Void


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.




swift-evolution mailing list

------------- End Message -------------

From James F