[swift-evolution] Request for Discussion: Setup closures

Anandabits matthew at anandabits.com
Fri Dec 4 15:41:24 CST 2015

let task = NSTask()>>{
>     launchPath = "/usr/bin/mdfind"
>     arguments = ["kMDItemDisplayName == *.playground"]
>     standardOutput = pipe
> }

I think something like this would be extremely useful, however I think the proposal as it is written is a bit more limited than I would like to see as it only applies to mutable properties.  

I don't have a concrete idea of exactly what I would prefer, but it would take the form of a general solution that would allow an initializer to accept initial values for some or all public stored properties from the caller.  The simplest case might look a lot like the compiler generated memberwise initializer for structs.  Slightly more complex cases might allow the caller to omit some properties if a default is specified by the type or by the initializer.  Going a step further, some initializers for a type may need to initialize some of the stored priorities directly and thus not allow those specific properties to be specified by the caller.

The goal is to allow flexible initialization for callers without sacrificing immutability and without requiring a ton of initializer overloads.

If others like this basic idea I will try to make it more concrete and write a proposal.

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

More information about the swift-evolution mailing list