logoalt Hacker News

cyberax • today at 7:57 PM • 6 replies • view on HN

It has an interesting code style, the comments go _after_ the function definition but before the opening bracket.

It looks weird, but it actually makes sense! The flow is more natural - first the function definition, and then the explanation of what it does. It also avoids repeating the function name.


Replies

compiler-guy • today at 10:28 PM

Code from that era predates the web, and a lot of open source style guides, and even most open source code itself.

So it came up in an era where folks were inventing their own style and the huge homogenizing influence of the gnu standards (and other open source projects) hadn't taken hold.

I like it. It feels like another language, and has its advantages. I really like to know of alternate ways of doing things, even if I don't adopt them myself.

spatulon • today at 9:12 PM

One of the more unusual aspects is the naming convention for types. Most type names use the a_ prefix (e.g. a_statement_ptr), but names beginning with a vowel start with an_ instead (e.g. an_object_lifetime_ptr).

1718627440 • today at 8:15 PM

I write comments about what a function does and it's interface before, but comments about the implementation after. Also my pre- and post-conditions go there of course. (I'm mostly writing in C.)

mhh__ • today at 8:01 PM

This is also where conditions go in languages with contracts, I like it

zerr • today at 8:05 PM

This is common in Lisps.

bobmarleybiceps • today at 8:10 PM

never occurred to me to write a comment there, but it actually looks kind of clean imho. Really old C code looked like

void func(var1, var2) int var1, char* var2. { ... }

perhaps some legacy from that? Probably not, but just first thing that popped into my head since it feels similar :shrug: