Uploaded image for project: 'Swift Driver'
  1. Swift Driver
  2. SWIFT-219

Add @dynamicMemberLookup to Document

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.0.8
    • Component/s: None
    • Labels:

      Description

      Swift 4.2 introduces the @dynamicMemberLookup attribute. Basically, this is just syntactic sugar, allowing you to use dot notation to look up arbitrary properties on a type.

      A natural place for us to use this is on documents. This will allow users to do things like the following:

      var doc: Document = ["a": 1, "b": 2]
      print(doc.a) // prints 1
      print(doc.x) // prints nil
      print(doc.b) // prints 2

      Implementing this will require adding the attribute to Document, and adding a new subscript(dynamicMember: ) method that behaves identically to our existing subscript getter. 

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              patrick.freed Patrick Freed
              Reporter:
              kaitlin.mahar Kaitlin Mahar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: