[swift-evolution] Returning nothing
james.froggatt at me.com
Fri Jul 22 10:12:10 CDT 2016
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 ------------
MsgID: <8F98C534-B577-4874-8075-F550CEC49438 at dimsumthinking.com>
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
swift-evolution at swift.org
------------- End Message -------------
From James F
More information about the swift-evolution