[swift-evolution] [Review] SE-0018 Flexible Memberwise Initialization

Matthew Johnson matthew at anandabits.com
Sun Jan 10 08:03:10 CST 2016



Sent from my iPad

> On Jan 10, 2016, at 4:08 AM, Thorsten Seitz via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>>> Am 10.01.2016 um 10:37 schrieb Brent Royal-Gordon <brent at architechies.com>:
>>> 
>>> On Jan 10, 2016, at 1:17 AM, Thorsten Seitz <tseitz42 at icloud.com> wrote:
>>> Yeah. Still brainstorming here :-)
>> 
>> So you know, I didn't really mean to put you specifically on the spot here; you're obviously trying to find concrete solutions to these problems.
> 
> No offense taken, I’m really interested in the opinion of everyone, that’s why I’m posting here :-)
> 
> 
>> But it seems to me that what we're going to end up with is that, instead of having this:
>> 
>>    public init(members...: Members) {
>>        self.members = members
>>    }
>> 
>> We'll have something more like:
>> 
>>    public init(members...: Members.Public.Initializable) {
>>        self.members.public.initializable = members
>>    }
> 
> Yes, that’s just what I’m trying to find out: I do like the Members-based idea but wanted to get a clearer understanding how it might *really* unfold before casting my vote for the current proposal. 

I will be sharing my vision for a long-term direction later today or tomorrow.  It allows us to accept this proposal as a step forward while still having a long-term path that relies on more general features, with a clean migration path when the more general features are ready.  

I hope you'll be willing to support this proposal as a good first step.

Matthew

> 
> 
>> Which looks a whole lot worse than the original when you compare it to this proposal's:
>> 
>>    public memberwise init(...) {}
> 
> You are certainly right, although one might argue that it has the advantage of spelling out a little bit more explicitly which members are hiding behind the "…“, i.e. it should be immediately clear that let properties with an initial value would not be part of Members.Public.Initializable, shouldn’t it?
> Same for internal or private properties.
> Whether that would be worth the longer form I’m not sure myself. At least it’s still just one simple assignment.
> 
> Exempting properties will certainly look even worse:
> 
> public init(members…: Members.Public.Initializable.except(i), x: Int) {
>    self.members.public.initializable.except(i) = members
>    i = 2 * x
> }
> 
> In addition the syntax would need some changes to differentiate between regular property access, accessing the special property "members" and narrowing operations.
> 
> -Thorsten
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list