[swift-evolution] Changing the curried static methods
Brandon Williams
mbw234 at gmail.com
Sat Mar 12 15:46:53 CST 2016
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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160312/775a0cdf/attachment.html>
More information about the swift-evolution
mailing list