🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #570

Re: Taming The Switch-Statement

#570
From: Michael S
Date: Mon, 19 Oct 2026 21:57
93 lines
5532 bytes
On Mon, 19 Oct 2026 23:27:03 +0200
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

> On 2026-10-19 21:35, Michael S wrote:
> > On Mon, 19 Oct 2026 15:44:40 +0200
> > Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> >   
> >> On 2026-10-18 18:32, Michael S wrote:  
> >>> On Sun, 18 Oct 2026 18:11:18 +0200
> >>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:  
> >>>>
> >>>> I don't recall to have used any language with infix-expressions
> >>>> that would have their monadic operators defined in postfix form.
> >>>>  
> >>>
> >>> I am a Bear of Very Little Brain, and long words Bother Me.  
> >>
> >> (If that quote is important for your argument, please explain.)
> >>  
> > 
> > Translation:
> > 1. I have no idea what unary * has to do with infix-expressions
> > 2. I don't appriciate use of the term "infix-expression" instead of
> > more common (in context of description of C and similar languages)
> > term 'binary operators'.
> > 3. I don't know what "monadic operators defined in postfix form"
> > means and have no plans to look for the meaning
> >   
> 
> I'm sorry, these are (AFAICT) common terms, and I thought obvious.
> So let me explain and amend with more text and examples...
> 
> Point 1. - I gave the hint that in languages that support RPN
> (= Reverse Polish Notation) things like monadic postfix operators
> (= having just _one_ argument applied _after_ the operator) are the
> natural way of writing expressions. Less so in languages, which are
> the majority since decades, that support expressions with infix
> operators (= the operator arguments left and right of the operator).
> 
> Point 2. - A "binary operator" may be the '*' in the expressions
>    a * b     typical infix notation (with parenthesis for precedence)
>    a b *     RPN
>    * a b     PN (Polish Notation)
> 
> A "binary operator" is something different from an "infix expression"
> (the first one of the three; the others are RPN and PN examples).
> That's why I took the appropriate term to explain what I intended to
> explain.
> 

O.k.

> Point 3. - "monadic" (see point 1). Applying to postfix form is best
> explained on another example; assume RPN
>    a -       monadic (unary) minus (on one argument)
>    a b -     dyadic (binary) minus (difference of two arguments)
> 
> Hope the terms are clear now. Now consider our original case, e.g.
> 
>    a * *b ...     multiply and dereference
>    a - -b ...     subtract and negate
> 
> as soon as we parse the second operator we know its kind. With postfix
> operators we'd have (assuming same semantics but with postfix
> operators)
> 
>    a * b * ...    now what is the second '*' at that point of parsing?

If C was as strongly typed from the beginning as it ended up in the 2nd
half of the 70s then it would make sense to use postfix . (dot) instead
of prefix * as dereference operator.
Unfortunately, in early stage of development C was almost untyped, so
something like that was out of question.

>    a - b - ...    we don't expect that second '-' to be a negation.
> 
> The compilers can handle every variant. For the users it's different;
> usually they seem to prefer unary operators to be prefixed (YMMV).
> 
> The question (concerning "C") was; would it have been "better" (in any
> respect) if the dereferencing operator would have been defined in "C"
> as postfix operator (as you seem to prefer).
> 
> Janis
> 

It would be certainly better in the context of type declarators. By now
mixing postfix with prefix is their most confusing part.
I have no strong opinion about advantages and disadvantages of postfix
in context of use of * in expressions, but suspect that in this context
the postfix will slightly reduce the need for parenthesis. 

Technical Details
Message-ID: <20261020005720.000026c2@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> <11arjmc$2qid7$1@dont-email.me> <11at5vi$5vu$1@reader2.panix.com> <11auad0$3no1k$1@dont-email.me> <11aupfl$3ul$1@reader2.panix.com> <11avmfb$55rt$1@dont-email.me> <11b2a6d$131h6$1@dont-email.me> <20261018172446.00002d43@yahoo.com> <11b2mqu$16mof$3@dont-email.me> <20261018182627.00001934@yahoo.com> <11b2r36$3pvda$8@dont-email.me> <20261018193201.00000b13@yahoo.com> <11b56s8$1kr9u$2@dont-email.me> <20261019223538.00006521@yahoo.com> <11b61v8$1kr9u$6@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 00:57:20 +0300
Organization: A noiseless patient Spider
Lines: 93
Message-ID: <20261020005720.000026c2@yahoo.com>
References: <119qf6l$2rmg3$1@dont-email.me>
	<11arjmc$2qid7$1@dont-email.me>
	<11at5vi$5vu$1@reader2.panix.com>
	<11auad0$3no1k$1@dont-email.me>
	<11aupfl$3ul$1@reader2.panix.com>
	<11avmfb$55rt$1@dont-email.me>
	<11b2a6d$131h6$1@dont-email.me>
	<20261018172446.00002d43@yahoo.com>
	<11b2mqu$16mof$3@dont-email.me>
	<20261018182627.00001934@yahoo.com>
	<11b2r36$3pvda$8@dont-email.me>
	<20261018193201.00000b13@yahoo.com>
	<11b56s8$1kr9u$2@dont-email.me>
	<20261019223538.00006521@yahoo.com>
	<11b61v8$1kr9u$6@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 19 Oct 2026 21:57:23 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2463771"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX180fvpBBuB2XRyupr0yL0rkG7/Ac/tTa7M="; posting-host="8f79a1fd3349fd33a92888f2407dde2d"
Cancel-Lock: sha1:M6nehV1pAiTENumCHIKP+umpdjU= sha256:7fTlci9kze3sClaQyBkHC3+bHOoppkhdkiNd17rvMkA=
	sha1:BpnW+mC6s0ZLcmqBJRjgkjjpjVk= sha256:zQXuh05itUQO0bB44/OUx35TAtEsl1WLn3/Vb22rKkc=
X-Newsreader: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-w64-mingw32)