The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Steffen Nurpmeso <steffen@sdaoden.eu>
To: John Cowan <cowan@ccil.org>
Cc: TUHS main list <tuhs@minnie.tuhs.org>
Subject: Re: [TUHS] tabs vs spaces - entab, detab
Date: Sun, 07 Mar 2021 00:43:20 +0100	[thread overview]
Message-ID: <20210306234320.92r5x%steffen@sdaoden.eu> (raw)
In-Reply-To: <CAD2gp_Qv7pO6P_LyZ=5zXm78GpBK4sUE2f8_4BBfyqJP7OSAJA@mail.gmail.com>

John Cowan wrote in
 <CAD2gp_Qv7pO6P_LyZ=5zXm78GpBK4sUE2f8_4BBfyqJP7OSAJA@mail.gmail.com>:
 |On Fri, Mar 5, 2021 at 9:14 AM Steffen Nurpmeso <steffen@sdaoden.eu> wrote:
 |> But, not important.  A real change to my coding style came when
 |> i looked around Plan9 source code, the pragmatism to simply not
 |> use spaces in language constructs aka statements at all, for
 |> example "if(a){" instead of "if(a) {" or "if (a) {", and let alone
 |> "if (a)\nALIGN{\nALIGN" and whatever else.
 |
 |That way lies APL madness.  To exemplify, Kona is an open-source
 |interpreter for Arthur Whitney's K version 3 language, which is closely
 |related to APL, but crams almost all of the APL operators onto single ASCII
 |characters with massive overloading.  For example, monadic ! is APL "iota",
 |but dyadic ! is "modulo" if both arguments are numbers and "rotate" if the
 |right argument is a number and the left argument is a vector.  What any of
 |these has to do with the rest is beyond me: I had to create a set of flash
 |cards to help me learn them all.
 |
 |Well, here's a procedure definition from the Kona source, in a file
 |helpfully named kc.c (almost all of the source files have 1-2 character
 |names):
 |
 |I wds_(K*a,FILE*f,I l)
 |{ S s=0,t=0;  I b=0,c=0,m=0,n=0,v=0;  K z=0; PDA p=0;
 |  I o=isatty(STDIN)&&f==stdin;
 |  if(-1==(c=getline_(&s,&n,f)))GC;
 |  appender(&t,&m,s,n);
 |  while(1==(v=complete(t,m,&p,0)))
 |  { b=parsedepth(p);
 |    if(o)prompt(b+l);
 |    if(-1==(c=getline_(&s,&n,f)))GC;
 |    appender(&t,&m,s,n); }
 |  SW(v){CS(2,show(kerr("unmatched"));GC) CS(3,show(kerr("nest")); GC)}
 |  z=newK(-3,m-1);
 |  strncpy(kC(z),t,m-1);
 | cleanup:
 |  free(s); free(t);
 |  if(p)pdafree(p);
 |  if((v||c==-1)&&z){cd(z); *a=0;}
 |  else *a=z;
 |  R v?-v:c; }    // -1 EOF, -2 unmatched, -3 nest
 |
 |If you want that sort of thing, you can certainly have it.  Note the
 |single-space ident and the cuddled right braces.  Note also the label
 |"cleanup:"; presumably a "goto cleanup;" is hidden somewhere in the
 |single-letter (of course) macros.

I do not, no.  The above has maybe the advantage that you really
really have to sit down and understand it as a whole before you
change anything, or apply patches.  This is very different to the
style that sometimes can be seen in projects with many people and
many patches, where code is packed in what-the-writer-thinks-is-a-
logical-block.  I (unfortunately) do it like that too, very
unfortunately with diverging positions of what a logical block is.
Just from a single pick, take Linux 5.10 ipc/sem.c.  You see

        sma = sem_alloc(nsems);
        if (!sma)
                return -ENOMEM;

        sma->sem_perm.mode = (semflg & S_IRWXUGO);
        sma->sem_perm.key = key;
1
        sma->sem_perm.security = NULL;
2       retval = security_sem_alloc(&sma->sem_perm);
        if (retval) {
                kvfree(sma);
                return retval;
        }

and i know that i would sometimes remove the newline 1 to finish
init of sem_perm, and instead introduce a newline before
2 instead.  I have no idea of kernel of course, here .security
depends on a special config and security_sem_alloc() just does
nothing without it (returning 0), not even setting .security to
NULL, whereas otherwise .security is definetely set by
lsm_ipc_alloc(), so maybe i understand 1, .. sometimes.  But
i would think about it.  And all of this just cannot happen with
the code above, i could use this style to fool myself into just
not thinking about just useless thoughts!

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

  parent reply	other threads:[~2021-03-06 23:43 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-04 16:52 Will Senn
2021-03-04 16:59 ` Clem Cole
2021-03-04 18:31   ` arnold
2021-03-04 19:23     ` Nemo Nusquam
2021-03-04 19:37       ` Steve Nickolas
2021-03-04 19:50         ` Rob Pike
2021-03-04 21:20           ` Robert Clausecker
2021-03-04 21:25           ` Will Senn
2021-03-05  9:58             ` John Gilmore
2021-03-06 21:31               ` Dave Horsfall
2021-03-06 21:38                 ` Larry McVoy
2021-03-06 22:05                   ` Clem Cole
2021-03-15  3:02                     ` John Cowan
2021-03-15 18:15                       ` Steffen Nurpmeso
2021-03-15 21:19                         ` Bakul Shah
2021-03-15 23:47                           ` Steffen Nurpmeso
2021-03-16  3:10                             ` Earl Baugh
2021-03-15 21:08                       ` Dave Horsfall
2021-03-15 21:12                         ` Steve Nickolas
2021-03-15 21:24                           ` Dave Horsfall
2021-03-15 22:06                             ` Adam Thornton
2021-03-16 13:25                             ` arnold
2021-03-17  5:10                       ` Greg 'groggy' Lehey
2021-03-06 21:40                 ` Steve Nickolas
2021-03-04 18:48   ` emanuel stiebler
2021-03-05  0:44     ` John Cowan
2021-03-05  0:55       ` Larry McVoy
2021-03-05  1:09         ` George Michaelson
2021-03-05  1:21           ` Larry McVoy
2021-03-05  1:29             ` Richard Salz
2021-03-04 18:33 ` John P. Linderman
2021-03-04 21:24 ` Greg 'groggy' Lehey
2021-03-04 21:27   ` Will Senn
2021-03-04 21:29     ` Greg 'groggy' Lehey
2021-03-04 21:42       ` Will Senn
2021-03-04 21:48       ` John P. Linderman
2021-03-04 22:08         ` Andy Kosela
2021-03-04 22:12           ` Greg 'groggy' Lehey
2021-03-05 14:13             ` Steffen Nurpmeso
2021-03-05 20:24               ` John Cowan
2021-03-05 21:51                 ` Bakul Shah
2021-03-06 23:43                 ` Steffen Nurpmeso [this message]
2021-03-05  0:15           ` Jon Steinhart
2021-03-06 21:22           ` Dave Horsfall
2021-03-06 23:58             ` Bakul Shah
2021-03-07  0:03               ` Jon Steinhart
2021-03-07  0:25               ` Steve Nickolas
2021-03-07  9:16               ` Brantley Coile
2021-03-05  9:50         ` [TUHS] tunefs -m 5% John Gilmore
2021-03-05 15:01           ` Grant Taylor via TUHS
2021-03-05 15:32           ` Theodore Ts'o
2021-03-06  1:18             ` Greg 'groggy' Lehey
2021-03-06  1:52               ` Warner Losh
2021-03-06 21:45                 ` Dave Horsfall
2021-03-06 22:03                   ` Larry McVoy
2021-03-09  4:59                     ` Greg 'groggy' Lehey
2021-03-06 23:52                   ` David Barto
2021-03-06  1:16           ` Greg 'groggy' Lehey
2021-03-04 22:10     ` [TUHS] tabs vs spaces - entab, detab Greg A. Woods
2021-03-05  1:41 ` alan
2021-03-05  1:55 ` alan
2021-03-05  2:06   ` Will Senn
2021-03-05 17:08     ` Clem Cole
2021-03-05 17:19       ` Richard Salz
2021-03-05 19:39         ` Lawrence Stewart
2021-03-05 19:51           ` Dan Halbert
2021-03-08  1:52       ` Will Senn
2021-03-05 16:43 ` Scot Jenkins via TUHS
2021-03-05 22:23   ` Bakul Shah
2021-03-06 20:51 ` Dave Horsfall
2021-03-06 21:01   ` Jon Steinhart
2021-03-06 21:19     ` Larry McVoy
2021-03-06 22:01       ` Clem Cole
2021-03-05 16:44 M Douglas McIlroy
2021-03-05 19:29 ` Greg A. Woods
2021-03-06 23:21   ` Steffen Nurpmeso
2021-03-05 22:50 Norman Wilson
2021-03-07  2:53 Nelson H. F. Beebe

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=20210306234320.92r5x%steffen@sdaoden.eu \
    --to=steffen@sdaoden.eu \
    --cc=cowan@ccil.org \
    --cc=tuhs@minnie.tuhs.org \
    /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).