[swift-evolution] [pitch] Eliminate the "T1 -> T2" syntax, require "(T1) -> T2"

Vladimir.S svabox at gmail.com
Fri Apr 22 15:34:26 CDT 2016


On 22.04.2016 22:27, L. Mihalkovic wrote:
> Void seems unequivocal, while () seems to beg for a context to be fully
> understood

Personally I don't insist to remove the Void, but actually I'd prefer to 
choose some only one variant how we can express an emtpy result. IMO there 
is something wrong for me if we have
func f1() -> () {...}
func f2() -> () {...}
in one source file and have
func fM() -> Void {..}
func fN() -> Void {..}
in another. Additionally this will cause questions of those who's new in 
Swift. But OK. Not a huge problem.

What I really don't like is that we can have all this:
func f1() -> (Void) {..}
func f2(Void) -> ((Void)) {..}
func f3() -> (((()))) {..}
func f4(((Void))) -> (Void) {..}
func f5() -> ((Void)) {..}
func f6((())) -> (((()))) {..}
and all is equivalent for
func f() -> () {..}

Why(what for) this all is possible? I'd like to remove this weird "feature" 
from Swift. Lets say compilation error if we have () in () or Void in (). 
Opinions?

>
> Regards
>
> On Apr 22, 2016, at 8:28 PM, Erica Sadun via swift-evolution
> <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>
>>
>>> On Apr 22, 2016, at 12:08 PM, Vladimir.S via swift-evolution
>>> <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> About the "Void".. I'm +1 on this idea, but asking myself if we can
>>> freely remove 'Void' from our language at all without any problem? Can't
>>> find the answer. It seems like we can, IMO using the syntax like () ->
>>> () is OK, clear and explicit, especially in "functional" word.
>>
>> I like having Void as a typealias of (), and would prefer to retain it in
>> the language if possible.
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list