[swift-evolution] [Pitch] Flattening the function type of unapplied instance methods

T.J. Usiyan griotspeak at gmail.com
Mon Feb 22 22:14:11 CST 2016

+1 for this. A clear win with regard to simplification.

On Mon, Feb 22, 2016 at 8:41 PM, Kevin Lundberg via swift-evolution <
swift-evolution at swift.org> wrote:

> On 2/22/2016 6:18 PM, Joe Groff wrote:
> If I understand the intent of `weakify` correctly, I think this kind of
> use case is already pretty severely curtailed by our removing the tuple
> splat feature, since you can no longer make `weakify` generic across
> multiple method signatures. Like the tuple splat feature, an explicit
> variadic splatting feature ought to make this possible for flattened method
> signatures:
> func weakify<Class: class, Args, Result>(instance: Class, method: (Class,
> Args...) -> Result) -> (Args...) -> Result {
>   return {[weak instance] args... in method(instance, args...) }
> }
> -Joe
> Agreed on the tuple splat removal point, but the common use cases I use
> this for today don't apply weakify to methods with more than one argument
> in practice. Even so, your example here is admittedly a pretty simple
> change to make to keep existing functionality if the curried form of this
> goes away, and this language change would make it haeder for people who
> want to do something similar to create a retain cycle scenario if they
> don't use something like weakify to safely pass method references around.
> I do like the current behavior, but given this you've convinced me that it
> may be best for it to change :)
> - Kevin
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160222/47d6466a/attachment.html>

More information about the swift-evolution mailing list