9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Jules Merit <jules.merit.eurocorp.us@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] Plan 9's style(6) manual page
Date: Sat,  7 Apr 2018 17:47:18 +0000	[thread overview]
Message-ID: <CAEVxPTMYEtkdWCr=6J41RcJQKG-HbdXovrZ=c5U_mP04N6Xs_A@mail.gmail.com> (raw)
In-Reply-To: <731be915ba87d1709cedd619aac23c0f@airmail.cc>

[-- Attachment #1: Type: text/plain, Size: 1861 bytes --]

That sums I.T. up

On Sat, Apr 7, 2018, 9:02 AM <8halfan@airmail.cc> wrote:

> 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.
>
>

[-- Attachment #2: Type: text/html, Size: 2439 bytes --]

  reply	other threads:[~2018-04-07 17:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-07 16:00 8halfan
2018-04-07 17:47 ` Jules Merit [this message]
2018-04-07 17:59 ` Digby R.S. Tarvin
2018-04-07 19:11   ` hiro
2018-04-07 20:14 ` Ori Bernstein
2018-04-07 20:38   ` tlaronde
2018-04-07 20:42   ` Skip Tavakkolian
2018-04-08  4:38   ` Rob Ote

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEVxPTMYEtkdWCr=6J41RcJQKG-HbdXovrZ=c5U_mP04N6Xs_A@mail.gmail.com' \
    --to=jules.merit.eurocorp.us@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).