🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #617

Re: Taming The Switch-Statement

#617
From: Michael S
Date: Tue, 20 Oct 2026 20:33
198 lines
8719 bytes
On Tue, 20 Oct 2026 15:11:35 +0100
bart <bc@freeuk.com> wrote:

> On 20/10/2026 02:03, Waldek Hebisch wrote:
> > bart <bc@freeuk.com> wrote:  
> >>
> >> OK. But they HAD to create C? There were quite a few languages in
> >> the early 70s too: like Pascal, Fortran, PL/I, Coral-66, plus of
> >> course BCPL and B. So why a new one?  
> > 
> > You ignore fact that Ritche wanted reasonably fast code from
> > very simple compiler.  
> 
> According to DC's quote from HOPL, it was also more fun to create a
> new language.
> 
> 
> > PL/I had most needed features.  But PL/I was a big language,
> > to run on small machine they would have to take tiny subset
> > and then add extentions.  Basicaly they would end up with a
> > language which is very far from PL/I.  
> 
> There were PL/360 and PL/M, although those were more specific, more 
> 'machine-oriented' languages. (I implemented one for PDP10 but it was
> a port of a systems language from a GEC machine.)
> 

PL/M is approximately contemporary to C, most likely Ritchie had first
compiler working few months before Kildall. But input language of the
early C compilers was likely further away from what it evolved later
than early PL/M to later its variant.
C was self-hosted on minicomputer from the beginning.
PL/M originally required more powerful and expensive host. Eventually
PL/M host requirements were reduced below those of C, but it took couple
of years.

> Anyway, a more general subset could have been used.
> 

I suppose that you wholeheartedly agree. I don't. I never found computer
language design fun.

> 
> > Similarly, BCPL was too complicated, B and C were simplifications
> > and adaptations small machine.
> > 
> > I think that Pascal was too late: nominally it was created earlier
> > but I think that it was available to Bell Labs only after they
> > did initial work leading to C.  And Pascal shared problem of
> > speed on small machines.  Note that later UCSD Pascal which
> > run on micros compiled to interpreted bytecode, which significantly
> > reduced performance.  
> 
> It would not have been hard to use Pascal as a starting point for a 
> workable systems language. Wirth wouldn't have approved, but his 
> languages were too pure, too academic; some of us had things we
> needed to get done!
> 
> Here I mean adapting Pascal for a competing systems language.
> 

Pascal without several extensions does not seem suitable for system
programming.

> In my hands some aspects would be simplified (eg. no nested
> functions, no closures), thus making it easier to generate decent
> code with a simple compiler.
> 

But then, it's not Pascal. And still needs extensions.

> 
> >   
> >> FORTRAN syntax looked nothing like C! Unless you mean the general
> >> pattern of 'INTEGER A, B' which was shared by half of all
> >> languages.  
> > 
> > I think more pattern of
> > 
> > INTEGER A(20), B
> > 
> > which has similar structure to C variable declarations.  
> 
> OK. That was typical for the time. But in Fortran it didn't get much 
> more complicated than that. Maybe 2D arrays and so on.
> 
> >  Of course,
> > FORTRAN had no pointers (and structures or unions), so Ritche had
> > to invent syntax for them.  
> 
> There were three languages from that era that I know had pointers or 
> references, and which allowed composing arbitrary types with arrays
> and pointers, two of which were Algol68 and Pascal.
> 
> Both used a 100% LTR form.
> 
> The other was C. There, several choices were made:
> 
> * To start with that Fortran style except that [] are used
> 
> * To decree that that 'A[20]' syntax is supposed to match indexing of
>    A as it might appear in an expression
> 
> * To introduce "*" as a prefix dereference operator in expressions ...
> 
> * ... which then means that a prefix "*" appears in the declaration
> too
> 
> * A further complication was to allow function pointers within that a
>    declaration list
> 
> * Yet one more which came later was to add 'const', where placement
> now gets confusing
> 
> But to stay with pointers, take this expression:
> 
>     *A[i]
> 
> C precedence rules mean this is parsed as *(A[i]), which means that a 
> type written as 'T *A[N]' must be an array of pointers to T (I had to 
> think for a few seconds!).
> 
> But suppose you wanted a pointer to array of T? The expression for
> that would be:
> 
>      (*A)[i]
> 
> And so the declaration has to be 'T (*A)[N]' too.
> 
> So it is unfortunate that parentheses used to control precedence in
> an expression now also have to appear in type declarations (where
> they are often next to () used for parameter lists, for further
> confusion).
> 
> ==============================================
> 
> So, what would have happened with a postfix deref op? (Ignore whether 
> '*' would still be a good choice.) My first example would be this:
> 
>     A*[i]
> 
> Here, it would mean that A is dereferenced, then indexed; A must then
> be a pointer to an array of T.
> 
> But suppose we wanted the original array of pointers to T, where you 
> index first then dereference. That is written like this:
> 
>     A[i]*
> 
> You simply swap the order of [] and *.
> 
> So, PARENTHESES HAVE BEEN ELIMINATED for purpose of disambiguating 
> array/pointer and pointer/array, both within expressions and within 
> type-declarations.
> 
> How about that? Further, most of the type-spec is now LTR; only the 
> base-type has to stay on the left. Access terms in expressions will
> be fully LTR.
> 
> > IMO C suffers because typedef was added late in the game and
> > function prototypes are much later.  Prototypes need types and
> > to get it one needs "hole" in variable declaration.  Where the
> > hole should be is specified by the C syntax, but placement of
> > hole is probably least clear aspect of declarations.  
> 
> I thought that 'hole' was where 'int A[10]' mean one thing in normal 
> declaration but another within a parameter list.
> 
> > IMO C declaration syntax was a mistake, but as real life shows
> > it was not a fatal mistake, people can adapt.  
> 
> A mistake that could so easily have been avoid by choosing a
> different precedence as shown above. Did none of the thousand people
> working at Bell Labs (according to a comment in DC's follow-ip) spot
> this and say anything?
> 

Methinks there were less than 100 people exposed to C before it became
too late. May be, just 50.

> Had no-one even glanced at a Pascal spec, if there was no working
> copy? It would have transformed C type syntax.
> 
> (ACTUALLY IT IS NOT TOO LATE. A secondary postfix deref op could have 
> been added. This could have been done 50 years ago, with the original 
> eventually deprecated.
> 
> But this is a common theme of mine whether I perceive a problem that 
> people grudgingly admit might not be idea. But nothing was ever done
> to fix it even after decades.)
> 

It was. There are many new languages.
Today, C sees little use outside of small to mid-sized mocrocontrollers
and OS kernels.
Most user-layer applications on general purpose computers are written
in newer languages.
Technical Details
Message-ID: <20261020233337.00004699@yahoo.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <119qf6l$2rmg3$1@dont-email.me> <11avmfb$55rt$1@dont-email.me> <11b0cvs$skc$1@reader2.panix.com> <11b0mfv$j5ll$1@dont-email.me> <11b3r71$6me$1@reader2.panix.com> <11b500f$216c4$1@dont-email.me> <11b6ekh$d2qm$1@paganini.bofh.team> <11b7sqn$32pr5$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Michael S <already5chosen@yahoo.com>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Tue, 20 Oct 2026 23:33:37 +0300
Organization: A noiseless patient Spider
Lines: 198
Message-ID: <20261020233337.00004699@yahoo.com>
References: <119qf6l$2rmg3$1@dont-email.me>
	<11avmfb$55rt$1@dont-email.me>
	<11b0cvs$skc$1@reader2.panix.com>
	<11b0mfv$j5ll$1@dont-email.me>
	<11b3r71$6me$1@reader2.panix.com>
	<11b500f$216c4$1@dont-email.me>
	<11b6ekh$d2qm$1@paganini.bofh.team>
	<11b7sqn$32pr5$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 20 Oct 2026 20:33:41 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3504182"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+PhKlMM9f79dVvKtMLxIfFSmOMqKvQn7A="; posting-host="925f45e5a71c85e1a82358d8d50bcd83"
Cancel-Lock: sha1:s9tIQdQ9nXd6i+y2da4h5ABW4/Q= sha256:rTT+MwKc4dB+qlpwoFnydwmlslBflSDwjma4BE65okA=
	sha1:ZwD7OahQoQA2TbWItszXtErvyEs= sha256:HMIvKMnabWZ5q5fE2T6HfRDvc3RsOFCSZRTFCO3MdUM=
X-Newsreader: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)