[swift-evolution] Proposal: helpers for initializing properties of same name as parameters

Jacob Bandes-Storch jtbandes at gmail.com
Sat Dec 5 20:49:54 CST 2015


The ability to use `var` in parameter lists / pattern matching is being
removed:
https://github.com/apple/swift-evolution/blob/7dc4dc47c43647dd1e60fe17074959dc3f056468/proposals/0003-remove-var-parameters-patterns.md

Jacob

On Sat, Dec 5, 2015 at 6:46 PM, David Waite via swift-evolution <
swift-evolution at swift.org> wrote:

> I don’t believe any more so than for let or var, which this effectively is
> a complement for.
>
> func foo(var externalName internalName:String) { print(internalName) }
>
>
> -DW
>
> On Dec 5, 2015, at 7:25 PM, Tal Atlas <me at tal.by> wrote:
>
> This syntax is confusing with that of defining the external keyword for
> the parameter.
>
> On Sat, Dec 5, 2015 at 9:24 PM David Waite via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>> A possible syntax, then:
>>
>>         init(set name:String, set score:Int) { }
>>
>> set would be a fourth parameter modifier alongside let, var, and inout -
>> only valid on initializers (not as useful and likely confusing in other
>> contexts). The local name has to match a parameter on the type. Like
>> let/var (but unlike inout) usage of ‘set’ on a initializer parameter does
>> not affect the caller or prototype conformance.
>>
>> -DW
>>
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151205/4da71a39/attachment.html>


More information about the swift-evolution mailing list