From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 References: <731be915ba87d1709cedd619aac23c0f@airmail.cc> In-Reply-To: <731be915ba87d1709cedd619aac23c0f@airmail.cc> From: Jules Merit Date: Sat, 7 Apr 2018 17:47:18 +0000 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary="f403043dd3bc306ada056945c43c" Subject: Re: [9fans] Plan 9's style(6) manual page Topicbox-Message-UUID: d3e388d8-ead9-11e9-9d60-3106f5b1d025 --f403043dd3bc306ada056945c43c Content-Type: text/plain; charset="UTF-8" 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. > > --f403043dd3bc306ada056945c43c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
That sums I.T. up

On Sat, Apr 7, 2018, 9:02 AM <8halfan@airmail.cc> wrot= e:
Just an amateur C programmer loo= king 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', et= c.

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= 9;t.
Why?

> no braces around single-line blocks (e.g., `if', `for', and `w= hile'
> 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:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 int foo;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 foo =3D 12;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 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.

--f403043dd3bc306ada056945c43c--