[u-u] wow, post-tested loops in sh

D. Hugh Redelmeier hugh at mimosa.com
Mon Jul 4 13:32:58 EDT 2016

| From: Dan Astoorian <djast at ecf.utoronto.ca>

| On Mon, 04 Jul 2016 10:25:24 EDT, "D. Hugh Redelmeier" writes:

| > There's another lesson to take from this.  The understanding of the shell 
| > that you had formed (and almost everyone else has too) is different from 
| > the real thing.  That suggests that the real thing is wrong -- badly 
| > designed for humans.
| So, a language is wrong if it's possible to write things in it that can
| be misunderstood or surprising?

No, that's not quite what I meant.  Nothing can prevent willful crap.
It is possible to make design choices to reduce accidents.  Just think
of the revolution in car safety, conveniently labelled post-Nader.

Car accidents and Airplane accidents are mostly operator errors.  But
that doesn't excuse the system from trying to reduce the occurence of
operator errors.  This has only been generally accepted in my living

|  Is C wrong because Duff's Device is possible?

Yes.  Or more accurately: Duff's Device is possible because of a
counter-intuitive design choice in C's case.  It even surprised the

Funny you should mention Duff's Device.  I wrote a bit about that in
the message and then deleted it.

I also designed something that abused case labels and was also
sometimes useful.  I was sworn to secrecy by Ritchie so I won't
divulge it here.

| I think the only moderately surprising aspect is the fact that the
| commands in the while condition's list can be separated by ";" (or, far
| more perversely, "&"), as opposed to "&&" or "||"; I don't think that
| many people would argue that:
|     while pgrep "myprocess" >/dev/null && test $i -lt 5
|     do
| 	: # ...
|     done
| should be syntactically invalid.
| For a program from 1977, I think it's done okay for itself.

The language was quite an improvement over the previous shell.  Still,
it missed some marks.  rc (10th Edition shell by Duff) looks a lot better.

But the program was pretty horrible according to those who worked with
it.  It was written with a layer of macros to make C look like Algol
68.  It depended on recovering from segfaults to allocate memory.

More information about the u-u mailing list