[swift-evolution] Proposal: helpers for initializing properties of same name as parameters
David Waite
david at alkaline-solutions.com
Sat Dec 5 20:46:26 CST 2015
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 <mailto: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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151205/ce470d64/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4139 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151205/ce470d64/attachment.p7s>
More information about the swift-evolution
mailing list