The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Bakul Shah <bakul@iitbombay.org>
To: John Cowan <cowan@ccil.org>
Cc: TUHS main list <tuhs@minnie.tuhs.org>
Subject: Re: [TUHS] tabs vs spaces - entab, detab
Date: Fri, 5 Mar 2021 13:51:09 -0800	[thread overview]
Message-ID: <C926D61B-DED8-4A0B-9E35-5A64DAE7855C@iitbombay.org> (raw)
In-Reply-To: <CAD2gp_Qv7pO6P_LyZ=5zXm78GpBK4sUE2f8_4BBfyqJP7OSAJA@mail.gmail.com>

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

> On Mar 5, 2021, at 12:24 PM, John Cowan <cowan@ccil.org> wrote:
> 
> On Fri, Mar 5, 2021 at 9:14 AM Steffen Nurpmeso <steffen@sdaoden.eu <mailto: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.

Not sure what this has to do with tabs but note that APL itself did a lot of punning in that unary and binary functions of the same name were related. K does something similar but perhaps not as consistently. 

> 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):

People should perhaps look at Whitney's original C code[1] that started all this (see below).

I can no longer compile this but it is worth studying. This was the genesis of both K & J languages. There is method to Whitney's madness but it takes a while to grok his style. Given that he has produced 6 or so versions of K, a specialized C compiler, as well as an OS prototype (kOS), clearly it has worked extremely well for him! Whiney once explained "It is a lot easier to find your errors in four lines of code than in four hundred." [2] Though his style is not for most people!

typedef char C;typedef long I;
typedef struct a{I t,r,d[3],p[2];}*A;
#define P printf
#define R return
#define V1(f) A f(w)A w;
#define V2(f) A f(a,w)A a,w;
#define DO(n,x) {I i=0,_n=(n);for(;i<_n;++i){x;}}
I *ma(n){R(I*)malloc(n*4);}mv(d,s,n)I *d,*s;{DO(n,d[i]=s[i]);}
tr(r,d)I *d;{I z=1;DO(r,z=z*d[i]);R z;}
A ga(t,r,d)I *d;{A z=(A)ma(5+tr(r,d));z->t=t,z->r=r,mv(z->d,d,r);
 R z;}
V1(iota){I n=*w->p;A z=ga(0,1,&n);DO(n,z->p[i]=i);R z;}
V2(plus){I r=w->r,*d=w->d,n=tr(r,d);A z=ga(0,r,d);
 DO(n,z->p[i]=a->p[i]+w->p[i]);R z;}
V2(from){I r=w->r-1,*d=w->d+1,n=tr(r,d);
 A z=ga(w->t,r,d);mv(z->p,w->p+(n**a->p),n);R z;}
V1(box){A z=ga(1,0,0);*z->p=(I)w;R z;}
V2(cat){I an=tr(a->r,a->d),wn=tr(w->r,w->d),n=an+wn;
 A z=ga(w->t,1,&n);mv(z->p,a->p,an);mv(z->p+an,w->p,wn);R z;}
V2(find){}
V2(rsh){I r=a->r?*a->d:1,n=tr(r,a->p),wn=tr(w->r,w->d);
 A z=ga(w->t,r,a->p);mv(z->p,w->p,wn=n>wn?wn:n);
 if(n-=wn)mv(z->p+wn,z->p,n);R z;}
V1(sha){A z=ga(0,1,&w->r);mv(z->p,w->d,w->r);R z;}
V1(id){R w;}V1(size){A z=ga(0,0,0);*z->p=w->r?*w->d:1;R z;}
pi(i){P("%d ",i);}nl(){P("\n");}
pr(w)A w;{I r=w->r,*d=w->d,n=tr(r,d);DO(r,pi(d[i]));nl();
 if(w->t)DO(n,P("< ");pr(w->p[i]))else DO(n,pi(w->p[i]));nl();}

C vt[]="+{~<#,";
A(*vd[])()={0,plus,from,find,0,rsh,cat},
 (*vm[])()={0,id,size,iota,box,sha,0};
I st[26]; qp(a){R  a>='a'&&a<='z';}qv(a){R a<'a';}
A ex(e)I *e;{I a=*e;
 if(qp(a)){if(e[1]=='=')R st[a-'a']=ex(e+2);a= st[ a-'a'];}
 R qv(a)?(*vm[a])(ex(e+1)):e[1]?(*vd[e[1]])(a,ex(e+2)):(A)a;}
noun(c){A z;if(c<'0'||c>'9')R 0;z=ga(0,0,0);*z->p=c-'0';R z;}
verb(c){I i=0;for(;vt[i];)if(vt[i++]==c)R i;R 0;}
I *wd(s)C *s;{I a,n=strlen(s),*e=ma(n+1);C c;
 DO(n,e[i]=(a=noun(c=s[i]))?a:(a=verb(c))?a:c);e[n]=0;R e;}

main(){C s[99];while(gets(s))pr(ex(wd(s)));}
[1] https://code.jsoftware.com/wiki/Essays/Incunabulum
One summer weekend in 1989, Arthur Whitney visited Ken Iverson at Kiln Farm and produced—on one page and in one afternoon—an interpreter fragment on the AT&T 3B1 computer. I (Roger Hui) studied this interpreter for about a week for its organization and programming style; and on Sunday, August 27, 1989, at about four o'clock in the afternoon, wrote the first line of code that became the implementation described in this document.

[2] http://archive.vector.org.uk/art10501320

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

  reply	other threads:[~2021-03-05 21:52 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 [this message]
2021-03-06 23:43                 ` Steffen Nurpmeso
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=C926D61B-DED8-4A0B-9E35-5A64DAE7855C@iitbombay.org \
    --to=bakul@iitbombay.org \
    --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).