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(a)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