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.
> 
> At present the type of properties and variables can be inferred as below:
> 
> class EvolutionManager {
>  let proposalManager = ProposalManager()           // type is inferred
> 
>  func proposeTopic(topic: String) {
>    let evolution = Evolution(topic: topic)         // type is inferred
>    proposalManager.proposeEvolution(evolution)
>  }
> }
> 
> However, function arguments cannot be inferred, as below:
> 
> class EvolutionManager {
>  func proposeEvolution(evolution: Evolution, proposalManager = 
> ProposalManager()) {       // compiler error, cannot infer type

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.

-Chris

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to