[swift-evolution] Proposal: Make $0 always refer to a closure’s first argument

Paul Cantrell cantrell at pobox.com
Thu Jan 21 15:05:18 CST 2016


> On Jan 20, 2016, at 4:55 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
> 
> On Jan 20, 2016, at 9:49 AM, Joe Groff via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>> I wouldn't go as far as to say it's a bug. It's known and occasionally useful for forwarding arguments. (For a while I had it as a fix-it for doing function representation conversions.)
>>> 
>>> I agree that having it always be the first argument is less surprising and probably more generally useful, though.
>> 
>> In the spirit of the Great Argument Simplification to distinguish arguments from tuples, we probably ought to introduce a separate '$*'-like sigil to bind "all arguments" distinct from $0.
> 
> Likewise, on the caller side, we should have a “splat” sigil to splat a tuple into the argument list of a call.  We need a similar thing for varargs to enable vararg forwarding as well.

Where does this leave the discussion, then? I’ve filed it as a bug, though there’s disagreement about whether it is.

Can we split this into two questions? My wish and dream would to get $0 fixed to match the docs (i.e. only match the first param) in 2.2. That’s an ongoing pain point.

The $* (or similar) feature would be handy, but seems like it should be accompanied by a larger vararg splatting discussion, and should probably fall to Swift 4+ given the release goals for Swift 3 — which is fine with me, but I’d really hate to have to wait that long to see $0 fixed.

Cheers,

Paul

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


More information about the swift-evolution mailing list