[swift-evolution] [Proposal Draft] partial initializers

David Owens II david at owensd.io
Tue Jan 12 02:00:36 CST 2016


> On Jan 11, 2016, at 9:49 PM, Brent Royal-Gordon <brent at architechies.com> wrote:
> 
> Keep in mind that it's only the assignment itself that would have to be in the initializer. You could still use a partial method to encapsulate the logic used to calculate the constant's value:
> 
> 	let foo: Foo
> 	var bar: Bar
> 	
> 	init(bar: Bar) {
> 		self.bar = bar
> 		foo = makeFoo()
> 		super.init()
> 	}
> 	
> 	partial(bar) func makeFoo() -> Foo {
> 		return Foo(bar: bar)
> 	}

True, but that is a bit awkward, especially if there are multiple lets you want to initialize. It could also expose implementation details in the case of being able to reset the data from the call as some of the `let` could potentially be private.

Also, Matthew, it would probably be good to remove the forwarding stuff from this proposal. The idea of these helper-type initializers really doesn’t need to be coupled with that to stand on its own.

-David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160112/b646368f/attachment.html>


More information about the swift-evolution mailing list