From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 7 Apr 2018 19:00:37 +0300 From: 8halfan@airmail.cc To: 9fans@9fans.net Message-ID: <731be915ba87d1709cedd619aac23c0f@airmail.cc> User-Agent: Roundcube Webmail/1.3.3 Subject: [9fans] Plan 9's style(6) manual page Topicbox-Message-UUID: d3de9936-ead9-11e9-9d60-3106f5b1d025 Just an amateur C programmer looking for answers. My main inspirations for code style is K&R 2nd edition and I'm curious about the instructions in Plan 9's style(6) manual page (for reference, http://man.cat-v.org/plan_9/6/style). I've tried to think about the motivations, but not everything is as clear as it seems. Going through style(6): > no white space before opening braces. > no white space after the keywords `if', `for', `while', etc. This is unique to Plan 9, it seems. I can't come up with a reason -- both BSD and Linux style use whitespace, and K&R does too, while Plan 9 doesn't. Why? > no braces around single-line blocks (e.g., `if', `for', and `while' > bodies). Apologies, but I'll have to Go and do it anyway :) > automatic variables (local variables inside a function) are never > initialized at declaration. Why not? In order to reduce visual clutter? It seems like this should be handled case-by-case: in some situations this just wastes lines: int foo; foo = 12; func("blah", &foo); > follow the standard idioms: use `x < 0' not `0 > x', etc. I'm guessing this is for consistency and more common coincidence with the flow of spoken language. > don't write `!strcmp' (nor `!memcmp', etc.) nor `if(memcmp(a, b, c))'; > always > explicitly compare the result of string or memory comparison with zero > using a > relational operator. Was that a common programmer error? cmp functions should return 0 if the arguments are identical. Smells like disaster in baking! > and this is not an exhaustive list Is there anything missing? That's all. Thanks for your time.