[swift-evolution] [Pitch] Remove type-inference for stored property
Jose Cheyo Jimenez
cheyo at masters3d.com
Mon Apr 10 12:22:15 CDT 2017
> On Apr 7, 2017, at 12:21 AM, Daniel Duan via swift-evolution <swift-evolution at swift.org> wrote:
> Hi all,
> In a discussion about inferring parameter types from default value, Slava brought up some performance problems caused by type inference for stored properties in side types:
> Towards the end, the post mentioned that some Swift team members contemplated requiring types for stored properties in type declarations. I think this idea deserves some more attention. Hence this last minute idea-floating.
My understanding is that the slowdowns are produced when the inference has to take into account generics. If somebody is using lots of generics and overloads; I would hope they would know that this can slow down compile times.
I am not sure how this can be communicated to the user other than showing a warning.
> In addition to solving a performance headache in implementation, there're always the general benefit of making type declartion more explicit and readable (clarity for reader should out-weigh pleasure of the author). Making the
> language slightly more consistent (we are not inferring types for default parameter values in function anyways).
> The cons for doing this are obvious too: the inference makes the language feels more friendly and is, undoubtedly, a beloved feature for many. This would be a source breaking change.
> Just thought I'd float the idea to gather some quick reaction. What do y'all think?
> Daniel Duan
> swift-evolution mailing list
> swift-evolution at swift.org
More information about the swift-evolution