<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Tony, thanks for the response!</div><div class=""><br class=""></div><div class="">In regards to why an enum w/ associated values:</div><div class=""><br class=""></div><div class="">- It avoids creating additional storage. (Admittedly, a very small amount, but the point still stands.)</div><div class="">- It deterministically defines that it’s either one or the other, and guards against someone trying to be clever and setting both the Pipe and Handle properties. Even if we do have a safeguard for that (like “setting the Pipe property nils out the File Handle property” and vice-versa), making it a type-safe enum improves API clarity. I’m generally not a fan of implicit API behaviors that require reading the fine print, and while they are necessary sometimes, I’d much prefer the class’s declaration makes it clear from the get-go. </div><div class="">- Furthermore on the previous point, it helps encourage safer client usage patterns for callers getting pre-launched NSTask objects from opaque factory methods. (I don’t see this pattern out in the wild very much, but I don’t want to rule it out, especially if Swift starts taking off on the server-side).</div><div class=""><br class=""></div><div class="">Dan</div><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 17, 2015, at 12:31 PM, Tony Parker <<a href="mailto:anthony.parker@apple.com" class="">anthony.parker@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Dan,<div class=""><br class=""></div><div class="">Thank you for your proposal. This is the right place to start discussion of it. If we want to do this then we would have to make changes in both Darwin and open source versions, to maintain source compatibility.</div><div class=""><br class=""></div><div class="">Out of curiosity, why propose an enum instead of an additional set of typed properties? Looking at the implementation of NSTask, it sure seems like we only expect either a file handle or pipe. I’m not sure if we would ever add another.</div><div class=""><br class=""></div><div class="">- Tony</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 17, 2015, at 11:34 AM, Dan Stenmark via swift-corelibs-dev <<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">This is my first proposal to swift-corelibs, so I’m not sure how much flexibility we have in terms of deviating from the darwin’s original Foundation definitions. That said, it’s always seemed a little screwy to me that NSTask's standardInput/standardOutput/standardError properties sacrifice any semblance of compile-time type safety by accepting id/AnyObject (which, at run time, must be either NSPipe or NSFileHandle, else it blows up). If allowed, I’d like to take the opportunity to modernize this in the open source version of Foundation.<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">public</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">class</span> NSTask : <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSObject</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">... <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="color: rgb(187, 44, 162);" class="">public</span> <span style="color: rgb(187, 44, 162);" class="">enum</span> IOType {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span> FileHandle(NSFileHandle)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span> Pipe(NSPipe)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""> <span style="color: rgb(187, 44, 162);" class="">public</span> <span style="color: rgb(187, 44, 162);" class="">var</span> standardInput: <span style="color: rgb(79, 129, 135);" class="">NSTask</span>.<span style="color: rgb(79, 129, 135);" class="">IOType</span>?</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">public</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> standardOutput: <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">NSTask</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">IOType</span>?</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">public</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> standardError: <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">NSTask</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">IOType</span>?</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">...</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div class=""><br class=""></div><div class="">Dan</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=U7z7oSqRMSwdl2rYt9JJ4zIFaeg4R-2FxExg9xndDuCbzJ4JLi5Gt6tW-2FMOPddk8KHiIg8kfIUnJL-2BVPRrj3-2FS5yDuH54VVgXuaLyDiL-2FEO7RXYCFnCOxQIR0AN0VDvxlHG19J-2FPIj1keT-2BHiW05Ilzp0cl4cMEavPBwPzbJIkstvKkVF-2FzBStdJVoB0g5DLfuRln-2FL7Jhj8emByOMvlmUSOI-2B99WvyeXGR9zasT7qKtM-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div>
_______________________________________________<br class="">swift-corelibs-dev mailing list<br class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-corelibs-dev" class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev</a><br class=""></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></body></html>