The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Clem Cole <clemc@ccc.com>
To: Will Senn <will.senn@gmail.com>
Cc: TUHS main list <tuhs@minnie.tuhs.org>
Subject: Re: [TUHS] v7 source code for sh
Date: Sat, 19 Feb 2022 11:04:28 -0500	[thread overview]
Message-ID: <CAC20D2NAL9+wACHKT8=mRYtKh=nkw=YYeffVvgCRiKfLa3s-ZQ@mail.gmail.com> (raw)
In-Reply-To: <69d88b37-5817-9a0d-4971-3d8641c2d153@gmail.com>

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

Sure - this is lovingly referred to as 'Bourne-gol.'  Steve Bourne was part
of the Algol-68 development team at Cambridge before he came to BTL.
Besides his being the 'editor' / 'release manager' of V7 (as Dennis is said
to exclaimed 'never again' after V6), please also look at the sources to
adb, srb's other major contribution (it is also written using his same
macros).  It's also why the syntax of his shell is basically Algol syntax.

Clem

On Sat, Feb 19, 2022 at 10:44 AM Will Senn <will.senn@gmail.com> wrote:

> I have been poring through the v7 source code lately, and came across an
> oddity I would like to know more about. Specifically, in sh. The code for
> sh is c, but it makes *extensive* use of of macros, for example:
>
> /usr/src/cmd/sh/word.c
> ...
> WHILE (c=nextc(0), space(c)) DONE
> ...
>
> The macros for sh are defined in mac.h:
>
> /usr/src/cmd/sh/mac.h
> ...
> #define BEGIN   {
> #define END     }
> #define SWITCH  switch(
> #define IN      ){
> #define ENDSW   }
> #define FOR     for(
> #define WHILE   while(
> #define DO      ){
> #define OD      ;}
> #define REP     do{
> #define PER     }while(
> #define DONE    );
> ...
>
> I can read the resultant code through the lens of my experience coding c,
> but I'm curious why the macros and how this came about? In v6, the sh
> source is straight up c. Is there a story behind it worth knowing?
>
> Thanks,
>
> Will
>

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

  parent reply	other threads:[~2022-02-19 16:06 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-19 15:43 Will Senn
2022-02-19 16:03 ` Steve Nickolas
2022-02-19 16:07   ` Clem Cole
2022-02-19 16:43   ` Steve Nickolas
2022-02-19 17:24   ` Ron Natalie
2022-02-19 16:04 ` Clem Cole [this message]
2022-02-19 16:06 ` Bakul Shah
2022-02-19 16:57   ` Will Senn
2022-02-19 17:44 Bakul Shah
2022-02-19 18:44 ` Rob Pike
2022-02-19 19:29   ` Clem Cole
2022-02-19 22:39   ` John Cowan
2022-02-19 23:11     ` Sven Mascheck
2022-02-19 23:34       ` Rob Pike
2022-02-19 23:36       ` silas poulson
2022-02-20 20:54       ` Chet Ramey
2022-02-20 21:02         ` Larry McVoy
2022-02-20 21:19           ` Chet Ramey
2022-02-20 21:19         ` Lyndon Nerenberg (VE7TFX/VE6BBM)
2022-02-20 22:39           ` Chet Ramey
2022-02-21  1:01             ` Dan Cross
2022-02-22  4:54               ` Dan Stromberg
2022-02-22  5:39                 ` Rob Pike
2022-02-22  5:54                   ` George Michaelson
2022-02-20  7:24 Rudi Blom
2022-02-21 17:58 Norman Wilson
2022-02-21 18:10 ` Rob Pike
2022-02-22  3:07 Brian Walden
2022-02-22 14:28 ` Chet Ramey
2022-02-22 14:47 ` Clem Cole

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='CAC20D2NAL9+wACHKT8=mRYtKh=nkw=YYeffVvgCRiKfLa3s-ZQ@mail.gmail.com' \
    --to=clemc@ccc.com \
    --cc=tuhs@minnie.tuhs.org \
    --cc=will.senn@gmail.com \
    /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).