4 ms·
the only Objective-C feature I miss when coding in other languages is named arguments(e.g. [self drawRectOfSize:size atPoint:point inColour:colour]). Doxygen, r
by kibwen 15y ago
the only Objective-C feature I miss when coding in other languages is named arguments(e.g. [self drawRectOfSize:size atPoint:point inColour:colour]). Doxygen, rdoc, javadoc and similar tools do a great job of generating API documentation from source, but I prefer the self-documenting nature of Objective-C method calls.
This sentiment seems to be at odds with the preference of
abs(val) {
over
int abs(int val) {
I'm all for type inference, I think it's wonderful. But if there's anywhere where I do want types to be explicit, it's in function signatures.
- tomp 15y agoAn interesting idea is for the types to be inferred, but not everytime you compile the code, but only the first time, then the compiler edits the source and adds the infered types. Or an IDE could do that.
- andrewflnr 15y agoI prefer my compiler to be a pure function. What if I'm generating source code and sending it over a pipe? I prefer not to need an IDE, either, though that's a tad more subjective.
- eevilspock 15y agoYou misread what he said. He misses named arguments, not typed ones.
- kibwen 15y agoOn the contrary, what he really misses is the "self-documenting nature" of Objective-C source code. And when it comes to functions, the four bits of documentation that are more important than any other are: 1) the order (or names) of its arguments (how to call it) 2) the types of its arguments (what to feed it) 3) the type of its return value(s) (what to expect) 4) whether the function maintains referential transparency (whether it plays nice with the rest of your program) Relying on type inference in the function signature abandons two of these and forces the casual reader to manually infer the manner in which the function may be safely used. Of course, in this position, one may always opt to use a documentation generation tool (doxygen, rdoc, javadoc, etc.)--however, when it comes to this, our code can no longer be considered to be self-documenting.
- eevilspock 15y agoWhat part of "THE ONLY Objective-C feature I miss when coding in other languages is NAMED ARGUMENTS" don't you understand?