Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referencing Objective-C key-paths #210

Merged
merged 6 commits into from Apr 7, 2016
Merged

Referencing Objective-C key-paths #210

merged 6 commits into from Apr 7, 2016

Conversation

hartbit
Copy link
Collaborator

@hartbit hartbit commented Mar 12, 2016

After discussing this proposal on the mailing list, with only positive feedback, I am now ready for having it reviewed.

@DougGregor
Copy link
Member

Please clarify the semantics of key paths that refer into collections, e.g., the example:

#keypath(Person.friends.firstName)

how is #keypath supposed to determine that "firstName" is meant to be a property on the element type of the "friends" collection? Is it tied to some KVC convention? Conformance to the Collection protocol? Something else? Otherwise, the proposal looks ready to go up for review.

@hartbit
Copy link
Collaborator Author

hartbit commented Mar 15, 2016

Would it be enough to say that paths that reference:

  • a type conforming to SequenceType are allowed to add a key to reference properties on that type and properties on the Element type
  • a type conforming to NSArray, NSDictionary, NSSet are allowed to add a key to reference properties on that type

Which leaves a whole for referencing properties on types inside a NSArray/NSDictionary/NSSet.

Any ideas?

On 15 Mar 2016, at 20:55, Doug Gregor notifications@github.com wrote:

Please clarify the semantics of key paths that refer into collections, e.g., the example:

#keypath(Person.friends.firstName)
how is #keypath supposed to determine that "firstName" is meant to be a property on the element type of the "friends" collection? Is it tied to some KVC convention? Conformance to the Collection protocol? Something else? Otherwise, the proposal looks ready to go up for review.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub #210 (comment)

@hartbit
Copy link
Collaborator Author

hartbit commented Mar 17, 2016

I added necessary details.

@DougGregor
Copy link
Member

Three minor comments and then I'd like to get this scheduled for review:

  1. Per recent discussions about the naming of the # expressions/directives, we should call this #keyPath
  2. I think the SequenceType conformance makes sense; the second bullet (about NSArray/NSDictionary/NSSet) isn't necessary because its behavior falls out from NSArray/NSDictionary/NSSet conforming to (or not conforming to) SequenceType.
  3. There is some implicit bridging going on here that could use some detailed design. If I refer to "Person.lastName.uppercased", that's a method on the value type String. At runtime, we're depending on getting the uppercaseString method on NSString. This may be as simple as saying that we follow the _ObjectiveCBridgeable conformance for any value type encountered along the way.

@hartbit
Copy link
Collaborator Author

hartbit commented Mar 24, 2016

  1. I changed it to #keyPath
  2. I simplified that whole paragraph to only mention the conformance to SequenceType.
  3. I hope you don't mind, but I copy pasted your third remark as-is under the uppercased example for potential implementors to see (it's chinese for me :))

@hartbit
Copy link
Collaborator Author

hartbit commented Apr 7, 2016

@DougGregor Do you need anything else before it's merged?

@DougGregor
Copy link
Member

My apologies for the delay; haven't have much -evolution time lately.

@DougGregor DougGregor merged commit a4c48d9 into apple:master Apr 7, 2016
@DougGregor
Copy link
Member

Let's just start it now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants