🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #600

Re: Taming The Switch-Statement

#600
From: David Brown
Date: Tue, 20 Oct 2026 08:25
120 lines
6667 bytes
On 19/10/2026 23:27, Janis Papanagnou 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.

I am afraid your terminology is further from common use than you 
thought.  ("Common use" of course depends on the context of the user - 
we are in the context of C programmers.)  Your posts can be clearer if 
you use appropriate terminology.


> 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).
> 

RPN - Reverse Polish Notation - is certainly a well-known term, though 
the abbreviation might seem out of place.  "Postfix" is the term most 
obvious in the context of C, as that is the term used in the standards.

And while "x y +" is clearly RPN, "x *" is not - it could be part of an 
infix expression, or a unary postfix operator.

"Monadic" /can/ refer to single argument functions or operators.  But it 
can also mean something completely different - monadic operations are 
operations that work on "packaged" types that unpack the value, apply a 
function, and pack it in again.  There is nothing of that kind in C (the 
language or standard library), but it is becoming a familiar term for 
users of C++ and is well-established in many other languages.

The C standard using "unary" for single-argument operators.

Similarly, "binary" is the normal term for two-argument operators, not 
"dyadic".  (Though I don't think "dyadic" has any other common meanings.)


> Point 2. - A "binary operator" may be the '*' in the expressions
>    a * b     typical infix notation (with parenthesis for precedence)
>    a b *     RPN

Normally known as "postfix", especially in C.

>    * a b     PN (Polish Notation)

There is no term "Polish Notation" - except as occasionally used to mean 
/postfix/ as a short form of "Reverse Polish Notation".  RPN was 
invented, or at least popularised, by the Polish logician Jan 
Łukasiewicz (I admit to looking that up on Wikipedia!).  There is no 
"PN" opposite.

> 
> 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.

Yes, binary operators can be prefix, infix or postfix.

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

Or, as the C world calls it, a postfix unary operator.

>    a b -     dyadic (binary) minus (difference of two arguments)
> 

Or, as the C world calls it, a syntax error or a refugee from 
comp.lang.forth.

> 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?
>    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
> 
Technical Details
Message-ID: <11b78i5$2m8c9$4@dont-email.me>
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: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Tue, 20 Oct 2026 10:25:41 +0200
Organization: A noiseless patient Spider
Lines: 120
Message-ID: <11b78i5$2m8c9$4@dont-email.me>
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=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 20 Oct 2026 08:25:42 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2826633"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/ddGX6LI6ShQ0H+Q5sdBLA3Rcjexgp2Vk="; posting-host="6609bebd5817c7daf1cbce2eb44e7728"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:KhO7fmwB92bj4XjtuP9Uxdy7k2A= sha256:K6IUMjeQH7nzpiPLvOi3lq8stqZrBFIDH3o9BIIM8TE=
	sha1:IwfGMP+siIVLLVIUCmRAUBktDlE= sha256:GzNlIufCcfmkzahTkNLdf55Zcekz7phOD5E33Cyp/nE=
Content-Language: en-GB, nb-NO
In-Reply-To: <11b61v8$1kr9u$6@dont-email.me>