[swift-evolution] Colon vs. equals
cacoyi at gmail.com
Fri Feb 5 18:36:47 CST 2016
Interesting point, I guess ":" in dictionary literals is to make the syntax
This is currently valid swift:
let x = [a = b]
Its type is: Array<Void>. It seems like the syntax is clearer if the
delimiter isn't a valid operator.
Also there's a problem with default value syntax:
func test(a: Int = 123)
This would be hard to read with only "=":
func test(a = Int = 123)
Also if the default value was an operator:
func test(a = Int -> Int = =)
Granted you could change the less commonly used default syntax, but it's
probably syntactically easier to differentiate user-controller delimiters
(assignment) and compiler-controller delimiters (:,). The example with
assignment in an array illustrates this.
I do agree '@available' though, it seems like it should be ":"
On Sat, Feb 6, 2016 at 10:27 AM, Brent Royal-Gordon via swift-evolution <
swift-evolution at swift.org> wrote:
> This is perhaps a bit nitpicky, but I've noticed that Swift sometimes uses
> colon to separate names and values, and sometimes uses equals. It's vaguely
> What do I mean? Well, our language has this:
> myFunc(foo, bar: baz)
> But it also has:
> @available(iOS, introduced=7.0, deprecated=8.0)
> You create a dictionary like this:
> let dict = ["key": "value"]
> But you set it like this:
> dict["key"] = "value"
> Is there some principle here? The @available case seems particularly
> strange to me, because those values read strongly like parameters to me.
> Brent Royal-Gordon
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution