5 ms·
The ability to easily grep for functions in C-like code is why I've come to appreciate projects defining their functions like: int foo_func(void) { You ca
by jolmg 7y ago
The ability to easily grep for functions in C-like code is why I've come to appreciate projects defining their functions like:
int
foo_func(void) {
You can grep for `^foo_func\b` to get to a declaration or definition, or `^foo_func\b.* {$` to get to a definition or `^foo_func\b.* ;` to get to a declaration. This is instead of using something like `^\w.* \bfoo_func\(`, which is what you'd need for:
int foo_func(void) {
By the way, anyone know of a way to insert a literal asterisk here without having to follow it up with a space?
- kahirsch 7y agoYes, I've been doing this since I saw it in the BSD source back in the '80s.
- paulddraper 7y agoJust one more reason to love languages with trailing instead of leading types (Scala, Typescript). fooFunc(): Int { "fooFunc returns an integer." Not "An integer is returned by fooFunc."