[swift-evolution] [Pitch] Enforce argument order for defaulted parameters

Matthew Johnson matthew at anandabits.com
Wed Mar 30 13:20:19 CDT 2016


One place where I believe argument re-ordering is useful is with memberwise arguments when you are initializing an instance.  Order usually plays no significant role with these arguments which are in some sense similar to assignment statements (which are inherently re-orderable).  

In fact, I have found myself wishing non-defaulted memberwise initializer parameters were re-orderable at times, especially when using the implicit memberwise initializer for a struct.  Source order for property declarations does not always match what makes the most sense at the initialization site (something that was pointed out numerous times during the review of my memberwise init proposal).

Matthew



> On Mar 30, 2016, at 11:59 AM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Many people are surprised when they find out defaulted parameters can be reordered, unlike required arguments. This special case adds complexity to the language, and runs against our general trend of treating argument labels as a significant part of an API's name, and preferring a single way of writing API calls. I think it's worth revisiting this design choice—is the special case worth the complexity? How many people take advantage of default argument reordering?
> 
> -Joe
> _______________________________________________
> 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