[swift-evolution] [Proposal Draft] partial initializers
    Brent Royal-Gordon 
    brent at architechies.com
       
    Mon Jan 11 23:49:48 CST 2016
    
    
  
> What I’m saying is that you don’t need the partial inits anymore, you still need some of your rules, but the actual “partial init” would be replaced by this modifier on functions.
> 
> Maybe something like this:
> 
>     initializer func reset() {
>         value1 = 0
>     }
> 
> The “initializer” modifier would be your “partial init” modifier.
I was about to post this idea (although I was going to suggest `partial func`, and possibly giving the `partial` keyword a parenthesized list of the properties that it expects to be initialized before you call it).
> For this to work though, you’d basically have to take the same limitation as convenience inits() today and disallow `let` values to be set. However, most of your other rules would apply to these.
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)
	}
-- 
Brent Royal-Gordon
Architechies
    
    
More information about the swift-evolution
mailing list