Groups | Search | Server Info | Login | Register


Groups > comp.lang.awk > #9752

Re: Operator precedence

From Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups comp.lang.awk
Subject Re: Operator precedence
Date 2024-05-24 01:53 +0200
Organization A noiseless patient Spider
Message-ID <v2okuh$1vrvh$1@dont-email.me> (permalink)
References <v2nium$1pl8f$1@dont-email.me> <20240523092856.646@kylheku.com> <87sey8movv.fsf@axel-reichert.de>

Show all headers | View raw


On 23.05.2024 19:14, Axel Reichert wrote:
> Kaz Kylheku <643-408-1753@kylheku.com> writes:
> 
>> Furthermore exponentation between on an intermediate precedence level
>> between unary minus and regular minus is simply insane.
> 
> This is a very good argument! [...]

I'd be interested why you think so. Unfortunately, and opposed to
the statement, I think there was no actual "argument" presented in
this quoted sentence.[*] - Please don't get me wrong; I'm really
interested in a relatable argument, and I also try to be unbiased!

If I understand Kaz' comment correctly, the ordering of the three
operators should be different? Are you saying that the order
  unary minus
  exponentiation
  binary minus
is somehow "wrong"? - Yet, I don't see why.
Moreover, what seams reasonable (to me) is that _unary_ operators
should (typically/always?) bind tighter than _binary_ operators!
This would imply that exponentiation does not bind higher than the
unary minus. (And that the order of the upthread posted Shell and
Algol 68 expressions would thus fit better.)

Different languages also differ in their implementation choice as
shown; besides languages mentioned I read that (for example) Eiffel
implements it the way that GNU Awk has chosen. - That's now 2:2,
but counting majority is of course also no convincing argument.

OTOH, exponentiation is (typically/always?) right associative, so
it's may be somehow sensible to be handled differently compared to
the other [commutative] binary operators?

You see I'm still undecided, and still looking for explanations.
OTOH, given that this had been discussed by computer scientists
and mathematicians without clear answer, it may boil down to just
be an opinion to be decided in one way or the other.

It is interesting what the [German] Wikipedia[**] says about that.
Specifically that there's (besides exponentiation, multiplication/
division, addition/subtraction) additional categories in programming
languages; the [unary] sign that normally has a yet higher priority
than the exponentiation. - Well...

Janis

[*] "simply insane" doesn't contribute to a substantial argument.

Also the upthread mentioned "BEDMAS" sort of rule doesn't seem
to apply since unary operators are not mentioned (and there's a
difference between subtraction and negation). In our schools we
also learned such simplified rules, in our case it was "Punkt vor
Strich" (meaning multiplication and division comes before addition
and subtraction). And we had also the practice that exponentiation
has a tighter binding than a unary minus sign (as Kaz suggested).

[**] https://de.wikipedia.org/wiki/Operatorrangfolge

Back to comp.lang.awk | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-23 16:13 +0200
  Re: Operator precedence Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-23 16:49 +0000
    Re: Operator precedence Axel Reichert <mail@axel-reichert.de> - 2024-05-23 19:14 +0200
      Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-24 01:53 +0200
        Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-24 04:41 +0200
          Re: Operator precedence Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-24 04:32 +0000
            Re: Operator precedence Axel Reichert <mail@axel-reichert.de> - 2024-05-25 13:34 +0200
              Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-25 23:31 +0200
                Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-26 00:03 +0200
                Re: Operator precedence Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-25 22:26 +0000
                Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-30 06:59 +0200
                Re: Operator precedence Axel Reichert <mail@axel-reichert.de> - 2024-05-30 10:24 +0200
                Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-31 17:08 +0200
                Re: Operator precedence Christian Weisgerber <naddy@mips.inka.de> - 2024-05-26 00:37 +0000
                Re: Operator precedence Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-26 02:06 +0000
                Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-30 07:26 +0200
                Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-30 07:06 +0200
                Re: Operator precedence Axel Reichert <mail@axel-reichert.de> - 2024-05-30 10:22 +0200
                Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-31 17:16 +0200
            Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-25 23:31 +0200
              Re: Operator precedence Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-26 01:29 +0000
        Re: Operator precedence Axel Reichert <mail@axel-reichert.de> - 2024-05-30 10:17 +0200
          Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-31 17:46 +0200
            Re: Operator precedence Axel Reichert <mail@axel-reichert.de> - 2024-06-01 09:11 +0200
      Re: Operator precedence Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-24 03:45 +0000
        Re: Operator precedence Axel Reichert <mail@axel-reichert.de> - 2024-05-25 13:09 +0200
          Re: Operator precedence Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-25 22:20 +0000

csiph-web