# iOS 10 By Tutorials - Function naming semantics

**URL:** <https://forums.kodeco.com/t/ios-10-by-tutorials-function-naming-semantics/21038>\
**Category:** iOS 10 by Tutorials\
**Created:** [October 11, 2016, 8:41pm UTC](https://forums.kodeco.com/t/ios-10-by-tutorials-function-naming-semantics/21038 "2016-10-11T20:41:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thegamingart](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/thegamingart/32/104125_2.png) [@thegamingart](https://forums.kodeco.com/u/thegamingart)\
**Post date:** [October 11, 2016, 8:41pm UTC](https://forums.kodeco.com/t/ios-10-by-tutorials-function-naming-semantics/21038/1 "2016-10-11T20:41:31Z")

</div>

This is a topic to discuss any function semantic questions/issue/concerns with Swift 3.0’s migration and the book semantics.

In Chapter 9: Property Animators, page 181 on the pre released book I noticed the following declarations within the `CGPoint+Trig.swift` file:

```
  func distance(toPoint point: CGPoint) -> CGFloat {
    return sqrt((point.x - x) * (point.x - x) + (point.y - y) * (point.y - y))
  }
  
  func normalize(weight: CGFloat) -> CGPoint {
    return CGPoint(x: x / weight, y: y / weight)
  }

```

The `distance(toPoint:)` function seems a bit out of place with the Swift 3 API guidelines. Wouldn’t you expect something more akin to the `public func distance(from start: String.Index, to end: String.Index) -> String.IndexDistance` declaration in `String`? Something more along the lines of `distance(to point: CGPoint) -> CGFloat`?

The same can be applied to the utility function:

```
  var toVector: CGVector {
    return CGVector(dx: x, dy: y)
  }

```

where the calculated property is very similar to

` open var ciColor: CIColor { get }`

available in `UIColor`.

Emulating the semantics, shouldn’t `toVector` just be `vector`?

There are quite a few other areas in the book where I see repeating semantics that reflect the older Swift 2 and Objective-C naming conventions. I actually would love to see something similar to the [TreeHouse blog post](http://blog.teamtreehouse.com/understanding-new-swift-3-api-design-guidelines?) detailing out appropriate naming conventions as with the grammatical rules within the Swift 3.0 API Guidelines, this can be confusing at times.

* * *

Edit:

Regarding the naming semantics of the `distance(toPoint:)` function, I did find the clause in the [Swift API guidelines](https://swift.org/documentation/api-design-guidelines/) addressing proper verbiage:

 ![](https://raywenderlich-com-v3-forums.s3.amazonaws.com/original/3X/0/a/0a9f329a1fd5238d0db63803b58d599332c87850.png)

 ![](https://raywenderlich-com-v3-forums.s3.amazonaws.com/original/3X/a/0/a08d971e94d58896375a392f56e8bb63dc4d5c77.png)

Nick me if I’m wrong lol.
