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

Thorsten Seitz tseitz42 at icloud.com
Sun Jan 10 04:08:27 CST 2016

> 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. 

> 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.


More information about the swift-evolution mailing list