Inline
On 11.05.2016 15:09, Thorsten Seitz via swift-evolution wrote:
Am 11. Mai 2016 um 05:33 schrieb Chris Lattner via swift-evolution
<[email protected]>:
On May 10, 2016, at 3:02 AM, Sam Dods via swift-evolution
<[email protected]> wrote:
I propose that function argument types could be omitted in the same way
as variable and property argument types are omitted when they are set at
point of definition.
[...]
We have a pretty strict rule here: types are allowed to be inferred in
implementations, but not interfaces. This is important for efficient
compilation, encourages people to think about their API interfaces, and
somewhat reduces the damage when they don’t.
+1
Sorry, but this("We have a pretty strict rule") seems just like not true.
The rule is broken as you can see (so not such a 'strict') :
public class A {
public var a = guessWhatTypeOfThisProperty()
}
// guessWhatTypeOfThisProperty is a global function defined far-far away
So, can't see any reason why Swift should not infer type of default
parameter *currently*. This will not break any 'strict' rule.
Or, what I'll probably prefer, we should *actually* disallow type inference
in interface part of type *if* assigned not simple 'raw' value like
Int/Double/String..
I.e.
public var a = 10 // OK, all is clear here
public var a = "sdfsdf" // OK
public var a = someFunction() // not OK - add type of `a` explicitly
And in this case, yes, there is no place for type inference for default
parameters.
-Thorsten
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution