Re:A proposal for named arguments for C++
by jjoonathan on Wednesday October 15, 2014 @11:51PM
(#8463285)
This is exactly why I like the Objective-C method call syntax. Instead of "mystery argument soup"
you get something that can be understood without taking a trip to the API docs:
It's a pity they are moving away from this syntax in Swift. It's the right move -- I hear nothing but hate for it from those who don't actually use it (i.e. the people who should be Swift's target audience) -- but it's still a pity.
[ Parent
| on HN ]
Re:A proposal for named arguments for C++
by Marat_Dukhan on Thursday October 16, 2014 @12:11AM
(#8463318)
I think C++ should use notation similar to designated initializers (that C++ adapted from C99) for names arguments, i.e. rectangle->set(.x = 10, .y = 20, .width = 20, .height = 20)
Otherwise, it would be very confusing that two different syntax are used for similar purpose.
Re:A proposal for named arguments for C++
by chingjun on Thursday October 16, 2014 @07:38AM
(#8464384)
Swift has named arguments, and it's called "external parameter name". Here's an example taken from Apple's documentation[1].
func join(string s1: String, toString s2: String, withJoiner joiner: String)
-> String {
return s1 + joiner + s2
}
join(string: "hello", toString: "world", withJoiner: ", ")
// returns "hello, world"
[1]: https://developer.apple.com/library/ios/documentation/swift/...