Convention to avoid conflicts with keywords


(Rudolf Adamkovič) #1

In Python, a single trailing underscore is used by convention to avoid conflicts with language keywords:

for case in cases
...

What about Swift?

Also, it would be great to document this in Swift’s API Design Guidelines.

R+

Rudolf Adamkovic


(Félix Cloutier) #2

Swift uses backticks: for `case` in cases

Additionally, you can use (almost) any character inside backticks, including operator characters.

Félix

···

Le 23 déc. 2015 à 18:01:20, Rudolf Adamkovič via swift-evolution <swift-evolution@swift.org> a écrit :

In Python, a single trailing underscore is used by convention to avoid conflicts with language keywords:

for case in cases
...

What about Swift?

Also, it would be great to document this in Swift’s API Design Guidelines.

R+

Rudolf Adamkovic

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Félix Cloutier) #3

Wait, the last part is not true.

Félix

···

Le 23 déc. 2015 à 18:05:03, Félix Cloutier via swift-evolution <swift-evolution@swift.org> a écrit :

Swift uses backticks: for `case` in cases

Additionally, you can use (almost) any character inside backticks, including operator characters.

Félix

Le 23 déc. 2015 à 18:01:20, Rudolf Adamkovič via swift-evolution <swift-evolution@swift.org> a écrit :

In Python, a single trailing underscore is used by convention to avoid conflicts with language keywords:

for case in cases
...

What about Swift?

Also, it would be great to document this in Swift’s API Design Guidelines.

R+

Rudolf Adamkovic

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Rudolf Adamkovič) #4

Ah, I missed that one. Thanks for letting me know, Félix!

From The Swift Programming Language:

To use a reserved word as an identifier, put a backtick (`) before and after it. For example, class is not a valid identifier, but `class` is valid.

Great!

R+

···

On 24 Dec 2015, at 00:05, Félix Cloutier <felixcca@yahoo.ca> wrote:

Swift uses backticks: for `case` in cases

Additionally, you can use (almost) any character inside backticks, including operator characters.

Félix

Le 23 déc. 2015 à 18:01:20, Rudolf Adamkovič via swift-evolution <swift-evolution@swift.org> a écrit :

In Python, a single trailing underscore is used by convention to avoid conflicts with language keywords:

for case in cases
...

What about Swift?

Also, it would be great to document this in Swift’s API Design Guidelines.

R+

Rudolf Adamkovic

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution