[swift-evolution] Proposal: Remove implicit tuple splat behavior from function applications

davesweeris at mac.com davesweeris at mac.com
Wed Jan 27 11:27:48 CST 2016


Fair enough. Can we get an explicit, well-designed version of this before we get rid of the implicit, poorly-designed version?

I can’t recall off the top my head where, but I know I’ve done something like this:
struct FunctionApplicator <T, U> {
    var args: T
    let function: T -> U
    init(args: T, function: T -> U) {
        self.args = args
        self.function = function
    }
    func apply() -> U {
        return function(args)
    }
}

Without tuple splatting, you’d need a FunctionApplicator1<T,U>, FunctionApplicator2<T,U,V>, FunctionApplicator3<T,U,V,W>, etc. They can’t even have the same name because Swift doesn’t support overloading type names for types with a different number of generic parameters.

- Dave Sweeris

> On Jan 27, 2016, at 08:48, Matthew Johnson via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> 
>> On Jan 27, 2016, at 4:18 AM, Nisse Bergman via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> -1 I use this in both my mocking API and in JSON deserialising/serializing.
>> I think this is a great thing to have
> 
> It would be great to have an explicit, well-designed version of this.  Nobody is arguing against that.  But there are quite a few problems with its current form.

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


More information about the swift-evolution mailing list