[swift-evolution] Changing the curried static methods

Developer devteam.codafi at gmail.com
Sat Mar 12 16:03:13 CST 2016


Hm, I always justified the existing behavior to myself because it reminds me of how Objective-C passes parameters in method calls (i.e. you get self, [SEL], params).

~Robert Widmann

2016/03/12 14:46、Brandon Williams via swift-evolution <swift-evolution at swift.org> のメッセージ:

> Right now instance methods on a type get a curried, static method for free, e.g. CGRect.insetBy is a curried function CGRect -> (CGFloat, CGFloat) -> CGRect. This is super cool and great for code reusability. 
> 
> Unfortunately, I think the order of the curry makes it difficult to use most of the time. With the above example you would use it as such:
> 
> CGRect.insetBy(rect)(10.0, 10.0)
> 
> That doesn’t read very nicely, and it’s more likely that you know (10.0, 10.0) before you know rect, hence you would want to call it as:
> 
> CGRect.insetBy(10.0, 10.0)(rect)
> 
> In general, I would expect a method:
> 
> struct A {
>   func method <B, C> (b: B) -> C
> }
> 
> to have a static method of the form
> 
> A.method: B -> A -> C
> 
> Does this make sense? Is there a reason for the current design that I’m not seeing?
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list