[swift-evolution] [Proposal Draft] property lists

Matthew Johnson matthew at anandabits.com
Wed Jan 13 11:55:55 CST 2016


> On Jan 13, 2016, at 11:46 AM, Patrick Gili <gili.patrick.r at gili-labs.com> wrote:
> 
> Not much has changed with regard to attribute accessors.
> 
> Here is a link to a great tutorial:
> 
> http://www.rubyist.net/~slagell/ruby/accessors.html <http://www.rubyist.net/~slagell/ruby/accessors.html>
> 
> Here is a link to the Ruby documentation the Module module, which contains documentation for attire, attr_accessor, attr_reader, and attr_writer:
> 
> http://ruby-doc.org/core-1.9.3/Module.html <http://ruby-doc.org/core-1.9.3/Module.html>
> 
> I think the Ruby notion of an attribute is the direction you're trying to take this. You can take your concept and build on it.

This hasn’t changed at all since I used Ruby.  It is really not like this proposal at all.  It is synthesizing the property (attribute) accessors themselves.  Swift does this automatically when you declare a stored property, or allows you to do so manually by writing computed accessors.

The idea in this proposal was that we could synthesize at least two useful memberwise features for a type from a list of properties - a memberwise partial initializer and a computed tuple property.

That said, I won’t be pursuing this proposal further given Chris’s comments about syntactic sugar proposals.  It seems doubtful that something like this would be considered in the Swift 3 timeframe and Swift 4 might bring macros which would hopefully make it possible to implement something like this ourselves if desired.

Matthew

> 
> My apologies regarding my comment about forwarding. I momentarily confused the concepts of protocol forwarding and parameter forwarding.

No problem, although I don’t see how either are directly related to this topic.

Matthew

> 
> Cheers,
> -Patrick
> 
> 
>> On Jan 13, 2016, at 11:21 AM, Matthew Johnson <matthew at anandabits.com <mailto:matthew at anandabits.com>> wrote:
>> 
>> 
>>> On Jan 13, 2016, at 9:15 AM, Patrick Gili <gili.patrick.r at gili-labs.com <mailto:gili.patrick.r at gili-labs.com>> wrote:
>>> 
>>> Ruby has the notion of attribute accessors, which is very similar to this proposal. If you align the proposal to look more like attribute accessors in Ruby, then it might play well with the forwarding, like the Ruby Forwardable module.
>> 
>> It’s been a while since I’ve written Ruby but I have written quite a bit of it in the past.  Did something change?  As far as I know attribute accessors are basically like properties.  
>> 
>> As far as forwarding goes, I have worked on a totally separate proposal for forwarding and have a second draft of that close to complete.  I don’t see how the two are related.
>> 
>> Matthew
>> 
>>> 
>>> -Patrick
>>> 
>>>> On Jan 11, 2016, at 6:02 PM, Matthew Johnson via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>> 
>>>> 
>>>> 
>>>> Sent from my iPhone
>>>> 
>>>> On Jan 11, 2016, at 4:49 PM, Greg Parker <gparker at apple.com <mailto:gparker at apple.com>> wrote:
>>>> 
>>>>> 
>>>>>> On Jan 11, 2016, at 9:17 AM, Matthew Johnson via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>>>> 
>>>>>>> On Jan 11, 2016, at 10:21 AM, Janosch Hildebrand <jnosh at jnosh.com <mailto:jnosh at jnosh.com>> wrote:
>>>>>>> 
>>>>>>> propertylist:
>>>>>>> Not a big fan of the name either, `propertyalias` came to mind but that sounds like it's only for a single property.
>>>>>> 
>>>>>> If you think of something better please let me know!
>>>>> 
>>>>> "property list" already means something in Cocoa. You are unlikely to get approval under that name.
>>>>> 
>>>> Good point!  Any better ideas?  I don't like it, just didn't think of a good one yet.
>>>> 
>>>>> 
>>>>> -- 
>>>>> Greg Parker     gparker at apple.com <mailto:gparker at apple.com>     Runtime Wrangler
>>>>> 
>>>>> 
>>>> 
>>>> _______________________________________________
>>>> swift-evolution mailing list
>>>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>>>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>>> 
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160113/506b121c/attachment.html>


More information about the swift-evolution mailing list