Groups | Search | Server Info | Login | Register
Groups > comp.lang.awk > #9753
| From | Janis Papanagnou <janis_papanagnou+ng@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.awk |
| Subject | Re: Operator precedence |
| Date | 2024-05-24 04:41 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <v2ouo9$2547f$1@dont-email.me> (permalink) |
| References | <v2nium$1pl8f$1@dont-email.me> <20240523092856.646@kylheku.com> <87sey8movv.fsf@axel-reichert.de> <v2okuh$1vrvh$1@dont-email.me> |
After pondering a bit more I think this is my personal resume...
On 24.05.2024 01:53, Janis Papanagnou wrote:
> [...]
> Moreover, what seams reasonable (to me) is that _unary_ operators
> should (typically/always?) bind tighter than _binary_ operators!
An example may make things probably more apparent; in the expression
5 * -3 ^ 2
it would never occur to me to not consider the "-3" as an entity.
Because of the typical inherently tight coupling of unary operators.
(Assuming an interpretation of
5 * -(3 ^ 2)
would look just wrong to me.)
> 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.)
BTW, Unix 'bc' also behaves that way
$ bc -l <<< " 5 * -3 ^ 2 "
45
<off-topic>
Let me add an Algol 68 anecdote (sort of)... You can of course adjust
the operator precedences in that language to fit your preferences.
And since you have more than one representation for the exponentiation
in Algol 68 - in the Genie compiler for example '^', 'UP', and '**' -
you can even change just one of them (if you like), for example
BEGIN
PRIO UP = 5;
INT a=5;
print ((a ^ 2, - a ^ 2, 0 - a ^ 2, newline));
print ((a UP 2, -a UP 2, 0-a UP 2, newline));
print ((a ** 2, -a ** 2, 0-a ** 2, newline));
SKIP
END
produces
+25 +25 -25
+25 +25 +25
+25 +25 -25
Scary! :-)
Janis
Back to comp.lang.awk | Previous | Next — Previous in thread | Next in thread | Find similar
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