News for hackers. Stuff that matters.
Re:The Curious Case of Swift's Adoption of Smalltalk Keyword... by ndotl on Sunday June 14, 2020 @01:26PM (#23519498)
Named arguments are great but should be used with care as they also create a reverse dependency. It prevents you from ever renaming the arguments in the future.
Re:The Curious Case of Swift's Adoption of Smalltalk Keyword... by wool_gather on Sunday June 14, 2020 @01:42PM (#23519624)
Accompanying saagarjha's point, you can freely rename the internal argument names, just not the external labels. Which is basically the same as changing the argument names in say C.
Re:The Curious Case of Swift's Adoption of Smalltalk Keyword... by paublyrne on Sunday June 14, 2020 @01:35PM (#23519566)
In the case of a library that would make this a breaking change you could add the new key rather than changing it, and support both while flagging old key usage with a deprecation warning.
Re:The Curious Case of Swift's Adoption of Smalltalk Keyword... by saagarjha on Sunday June 14, 2020 @01:28PM (#23519511)
Just like you can't ever rename the function in the future?
Re:The Curious Case of Swift's Adoption of Smalltalk Keyword... by dep_b on Sunday June 14, 2020 @02:16PM (#23519897)
You can mark it as deprecated with a reference to the replacing function. As long as the argument types match you can automatically refactor
Re:The Curious Case of Swift's Adoption of Smalltalk Keyword... by DagAgren on Sunday June 14, 2020 @03:23PM (#23520538)
This is already the case with the name of your function. And named arguments are basically just an extension of the name of your function.
Re:The Curious Case of Swift's Adoption of Smalltalk Keyword... by fsloth on Sunday June 14, 2020 @01:39PM (#23519594)
Why would it? When you change the name of nth argument from foo to bar, compile will fail and then you just need to do a global rename. Is there any scenario where this would not be feasible?
Re:The Curious Case of Swift's Adoption of Smalltalk Keyword... by wool_gather on Sunday June 14, 2020 @02:05PM (#23519806)
The caller can't do a global rename if they don't own the source of the function -- because it's in a library. Which is what parent meant by "reverse dependency": the library's interface is constrained by the fact that it has users.
Re:The Curious Case of Swift's Adoption of Smalltalk Keyword... by fsloth on Monday June 15, 2020 @01:06AM (#23523963)
Surely if the library interface changes the users can change their own code? That's why we have versioning of libraries - so that users of the library can take intelligently new versions into use, and especially so they are aware if (and when) the interface changes.
Re:The Curious Case of Swift's Adoption of Smalltalk Keyword... by DagAgren on Sunday June 14, 2020 @03:22PM (#23520531)
But this is already the case for the name of the function. Semantically, named arguments are just part of the name of the function.