3 ms·
In my opinion, "u8 foo() {}" looks and reads better than both of those.
by lone_haxx0r 7y ago
In my opinion, "u8 foo() {}" looks and reads better than both of those.
- gen220 7y agoI’d agree that it looks better in isolation. I think that the advantage of leading with `fn` arrives when you have paragraphs of functions to scan through. Leading with a consistent word (be it fn, func, or whatever) immediately and disambiguously identifies the line as defining a function (rather than a variable, or whatever), which is a useful landmark to anchor on or pivot from.
- umanwizard 7y agoSo, using grep or a similar tool, how would you find the definition of the function, separately from its uses? In a Rust codebase I could just run `grep -r "fn foo" .` and find the definition immediately. Clearly this doesn’t matter if you’re in an IDE with a working “find definition” feature, but that’s often enough not the case that I find easily greppable definitions to be a gigantic advantage.
- jcelerier 7y agocome on, C++ IDEs had "go to definition" features for literal decades
- umanwizard 7y agoIn what way does this contradict my comment?
- the_why_of_y 7y agoBut it comes at a cost: this is the reason why struct declarations need to end with "};" in C.