Path: csiph.com!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.lang.awk Subject: Re: Operator precedence Date: Sun, 26 May 2024 02:06:40 -0000 (UTC) Organization: A noiseless patient Spider Lines: 44 Message-ID: <20240525185349.904@kylheku.com> References: <20240523092856.646@kylheku.com> <87sey8movv.fsf@axel-reichert.de> <20240523210755.307@kylheku.com> <87zfsektvi.fsf@axel-reichert.de> Injection-Date: Sun, 26 May 2024 04:06:40 +0200 (CEST) Injection-Info: dont-email.me; posting-host="058c0fa05b6b3793bcde5f0cd05a6280"; logging-data="3415242"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vF4rH+P3sdBgHNRlThRd4Bu22y8YgABI=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:QCCnaMtyiwsmef2p+xkvYbx/G/0= Xref: csiph.com comp.lang.awk:9765 On 2024-05-26, Christian Weisgerber wrote: > On 2024-05-25, Janis Papanagnou wrote: > >> People should be anyway aware of the operator precedences in the >> various programming languages since there are obviously yet worse >> definitions than the one we've been discussing here. > > Which is why BSD has had an operator(7) man page about "C operator > precedence and order of evaluation" since 1990. This discussion has convinced me that unary operators must not be clumped together and put into a single precedence level. For instance, if we have the C-like expression -*p/*q it should ideally be -(*p/*q) and not as it is now: (-*p)/(*q) due the unary minus being clumped with dereference. Unary minus should not be a distinct operator from binary minus. Unary minus should denote the elision of an identity element term, so that - X not only means the same as 0 - X, but is considered to be the same notation, just with the additive identity element not show. We could correctly parse it as a binary minus by putting the element back in. This can make a difference easily. Consider that the unsigned types in C have a definition for unary minus. If *p is of type unsigned int, and its value is 1, then (-*p) is UINT_MAX. *q is 4 then we get UINT_MAX / 4. Under the proposedd rule, we would get something else: 1/4 producing 0, and that negating to 0. -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca