[swift-evolution] Returning nothing
James Froggatt
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 ------------
Group: gmane.comp.lang.swift.evolution
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.
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
_______________________________________________
swift-evolution mailing list
swift-evolution at swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
���~…
------------- End Message -------------
From James F
More information about the swift-evolution
mailing list