[swift-evolution] Colon vs. equals

Maximilian Hünenberger m.huenenberger at me.com
Fri Feb 5 19:22:50 CST 2016


Inline

Am 06.02.2016 um 02:07 schrieb Brent Royal-Gordon <brent at architechies.com>:

>> If ":" should be replaced by "=" than only at the call site to make it more consistent with variable declaration and initialization:
>> 
>>        myFunc(number = 4, string = 7)
>> 
>>        func myFunc(number: Int, string: String) {}
>> 
>> Although writing "=" instead of ":" in methods in 1.5 years Swift and over 20 years Objective-C would be a huge change.
> 
> To be clear, I like colon in parameter lists; I don't see passing a parameter as setting something.
> 

I cannot say whether I like ":" in parameter lists or if I'm just used to them...

Though setting parameters doesn't seem wrong to me. In fact value types get copied to a new parameter which is declared in the function signature.

> I suppose mainly what I'd like is for attributes to change:
> 
>    @available(iOS, introduced: 7.0, deprecated: 8.0)
> 
> And *possibly* for dictionary literals to change:
> 
>    let dict = ["key" = "value"]    // Also, the shorthand syntax would be [String = String]
> 
> Although dictionary literals seem like a relatively high-impact change compared to its value.

Yeah that would be true and also ":" in dictionaries reads to me like a "map this value to another one". So it would rather be "=>" than "=" which reads like an assignment to the left "<=".

- Maximilian

> 
> -- 
> Brent Royal-Gordon
> Architechies
> 


More information about the swift-evolution mailing list