> On Mar 22, 2017, at 11:41 AM, Ricardo Parada <rpar...@mac.com> wrote: > > Agree. > > Another question. If `Bag` does have a static thing called `myStaticThingy` > would you refer to it as: > > Bag.Type#myStaticThingy
I would expect that to work eventually but I’m not sure if it would be included in the initial proposal or not. > > ? > > >> On Mar 22, 2017, at 12:37 PM, Matthew Johnson <matt...@anandabits.com >> <mailto:matt...@anandabits.com>> wrote: >> >>> >>> On Mar 22, 2017, at 11:16 AM, Ricardo Parada <rpar...@mac.com >>> <mailto:rpar...@mac.com>> wrote: >>> >>> I see three possibilities: >>> >>> 1) # + «space» +«path» like this: >>> >>> let path = # Bag.things[0].name >>> bag[path] >>> bag[# Bag.things[0].name] >>> bag[# .things[0].name] // Root is inferred as Bag >>> bag.things[0][# Thing.name] >>> bag.things[0][# .name] // Root is inferred as Thing >>> >>> 2) # + «path» like this:: >>> >>> let path = #Bag.things[0].name >>> bag[path] >>> bag[#Bag.things[0].name] >>> bag[# .things[0].name] // Root is inferred as Bag >>> bag.things[0][#Thing.name] >>> bag.things[0][#.name] // Root is inferred as Thing >>> >>> 3) «Root» + # + «path» like this: >>> >>> let path = Bag#things[0].name >>> bag[path] >>> bag[Bag#things[0].name] >>> bag[#things[0].name] >>> bag.things[0][#name] >>> bag.things[0][Thing#name] >> >> I prefer the third option. I don’t think we should go with the first >> option. Allowing (or requiring) a space seems likely to be confusing. Both >> the first and the second still have potential to be confusing. If `Bag` has >> a static property named `things` people could be confused about what >> `#Bag.things` refers to. If we’re going to use a special sigil it should be >> positioned such that it eliminates potential for that kind of confusion. >> >>> >>> >>> >>>> On Mar 22, 2017, at 11:47 AM, Matthew Johnson <matt...@anandabits.com >>>> <mailto:matt...@anandabits.com>> wrote: >>>> >>>> >>>>> On Mar 22, 2017, at 10:36 AM, Vladimir.S via swift-evolution >>>>> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote: >>>>> >>>>> On 22.03.2017 17:37, Ricardo Parada wrote: >>>>>> >>>>>> >>>>>>> On Mar 22, 2017, at 9:30 AM, Vladimir.S <sva...@gmail.com >>>>>>> <mailto:sva...@gmail.com>> wrote: >>>>>>> >>>>>>> let path = @Bag.things[0].name >>>>>>> >>>>>>> bag@path >>>>>>> bag@.things[0].name >>>>>>> bag@Bag.things <mailto:bag@Bag.things>[0].name >>>>>>> bag.things[0]@.name >>>>>>> bag.things[0]@Thing.name >>>>>> >>>>>> It sounds like the @ character is serving two different purposes which >>>>>> confused me at first. >>>>>> >>>>>> If I understood correctly, you are using it to get the key path but also >>>>>> to apply the key path to the bag struct and get the corresponding value. >>>>>> >>>>> >>>>> Yes. And the initial proposal suggest the following syntax accordingly: >>>>> >>>>> let path = Bag.things[0].name >>>>> bag[path] >>>>> bag[.things[0].name] >>>>> bag[Bag.things[0].name] >>>>> bag.things[0][.name] >>>>> bag.things[0][Thing.name] >>>> >>>> # makes a lot more sense than @ as a sigil. It follows from #selector and >>>> #keyPath. These are the most similar language features right now where >>>> the compiler produces special values. I think it’s also worth noticing >>>> that values produced by #selector and #keyPath are used in normal ways. >>>> There is no magic syntax for their use, just a typed value. If we’re >>>> going to make a change we should use # instead of `.` for accessing these >>>> special values but we should stick with subscript for use. >>>> >>>>> _______________________________________________ >>>>> swift-evolution mailing list >>>>> swift-evolution@swift.org <mailto:swift-evolution@swift.org> >>>>> https://lists.swift.org/mailman/listinfo/swift-evolution >>>>> <https://lists.swift.org/mailman/listinfo/swift-evolution>
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution