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

Chris Lattner clattner at apple.com
Wed Jan 27 12:09:46 CST 2016

> On Jan 21, 2016, at 1:05 PM, Paul Cantrell <cantrell at pobox.com> wrote:
>> On Jan 20, 2016, at 4:55 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org <mailto: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.

I’m sorry, I’ve lost context on what the proposal here is.  Can you please restate it?  To me, it seems most natural that $0 always refer to the first parameter of a closure.


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

More information about the swift-evolution mailing list