[swift-evolution] [Proposal Draft] parameter forwarding
Matthew Johnson
matthew at anandabits.com
Tue Jan 12 08:14:11 CST 2016
Sent from my iPad
On Jan 12, 2016, at 12:11 AM, Brent Royal-Gordon <brent at architechies.com> wrote:
>> Or is tuple packing and unpacking the best we can hope for?
>
> If we do go the tuple packing/unpacking route, I wonder if we can add syntax that gets the parameter and return types of a function:
I thought about this last night. Something like this might also allow the default parameter values the function declares to appear in the forwarding signature.
With the generalized naming proposal we could get pretty close to forwarding to any function with defaults intact. But where types are required to disambiguate it would still not be possible. Maybe that is an acceptable tradeoff though.
Matthew
>
> func fooWithLogging(*params: foo.Parameters) -> foo.Return {
> print("Calling foo with \(params)")
>
> let value = foo(*params)
>
> print(" Returned \(value)")
> return value
> }
>
> (Here I'm using a Ruby/Perl 6-style splat, since we're leaning pretty heavily on `...` already.)
>
> --
> Brent Royal-Gordon
> Architechies
>
More information about the swift-evolution
mailing list