Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Where are you getting this from?

Swift’s mandatory named parameters come from Objective-C. For the most part only the bracket placement is different.



Mandatory names parameters?

You have been able to provide anonymous arguments since I first started playing with Swift in 2.0. The function just has to define it that way.


Swift supports default and objc doesn’t. This makes calls smaller. Swift also has argument hiding with the underscore before the parameter. Swift also ask variable arguments. Hiding named parameters and variable arguments make calls much smaller. My point stands.


That's not really "much" longer. And in some cases the brevity saved could really increase obfuscation and confusion.


Yes it is; especially, if there’s long parameter names. And I disagree with the obfuscation and confusion, but that’s a discussion on Swifts goal of self documentation not code length.


you can define ObjC method parameters with empty selector names if you want.

This for example is perfectly legal ObjC, callable as [foo gimmeAString:10 :"hey "].

  - (NSString*)gimmeAString:(NSUInteger)count :(NSString*)piece {
      return [@"" stringByPaddingToLength:count withString:piece startingAtIndex:0];
  }




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: