[swift-evolution] an observation on colons in variable type declarations

Taras Zakharko taras.zakharko at uzh.ch
Wed Feb 10 11:44:19 CST 2016


It really depends on what you are used to. Swift notation comes from mathematics and formal computer science. You seem to be more used to the Fortran/ALGOL/C syntax. Personally, I prefer the Swift way, its cleaner and less confusing to me. 

At any rate, I don’t think there is a valid reason to reconsider this design aspect of the language. 

> On 09 Feb 2016, at 23:45, Oliver M via swift-evolution <swift-evolution at swift.org> wrote:
> 
> A brief observation regarding variable type declarations
> 
> I find the colon in variable type declarations a little odd.
> Consider the following:
> 
> var welcomeMessage: String
> 
> wouldn't this be cleaner simply written as
> 
> var welcomeMessage String
> 
> 
> the documentation says to read the colon ':' as "of type" in such situations
> 
> but does the type "String" itself not imply 'of type String'
> 
> 
> 
> Consider the colon in a function declaration:
> 
> func sayHello(personName: String) {}
> 
> I would read the portion within the brackets as:
> parameter named personName takes value of type String (because you input values when calling functions)
> with the colon reading 'takes value' and "String" again reading 'of type String'
> 
> 
> 
> I find the colon ':' strongly associated with function input values, and with associations [key:value pairs etc]
> but variables…you don't input anything and they are not inherently associations.
> 
> 
> When coding half asleep I find myself compelled to input a value wherever I see a ':' and I can see myself typing something really really silly
> 
> var myIndex: "Int" 
> myIndex = 0
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160210/2dcf1019/attachment.html>


More information about the swift-evolution mailing list