[swift-evolution] [Pitch] Unifying init parameters with properties

Ross O'Brien narrativium at gmail.com
Thu Apr 14 10:40:49 CDT 2016


(re-added swift-evolution)

I would think so. It's an abbreviation of a given init function, so you
would call other self.init() or super.init() functions normally. Saves on
complication.


Alternatively, perhaps you could do this:

init(self.foo: String, super.bar: String, super.baz: Int)

as an abbreviation of
init(foo: String, bar: String, baz: Int)
{
    self.foo = foo
    super.init(bar: bar, baz: baz)
}

I think this would probably require allowing parameters to stay
re-orderable, though (in case super's init is "init(baz: Int, bar: String)"
).



On Thu, Apr 14, 2016 at 4:29 PM, Vladimir.S wrote:

> +1. This will make our life easier, it is clear and explicit about the
> result.
>
> I assume that there must be a constrain : you can use in init(...) only
> props introduced in the same class, not in parent class.
>
>
> On 14.04.2016 17:32, Ross O'Brien via swift-evolution wrote:
>
>> init(self.foo: String, self.bar: String, self.baz: Int)
>>
>> {
>>
>> barCount = bar.characters.count
>>
>> }
>>
>> }
>>
>>
>> Less boilerplate, more focus on the properties which need to be generated.
>>
>> Thoughts?
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160414/127c850d/attachment.html>


More information about the swift-evolution mailing list