Re: silly question: prefix vs postfix ops

Ralph Boland <rpboland@gmail.com>
Tue, 4 Mar 2008 17:59:29 -0800 (PST)

          From comp.compilers

Related articles
[2 earlier articles]
Re: silly question: prefix vs postfix ops mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2008-03-03)
Re: silly question: prefix vs postfix ops gah@ugcs.caltech.edu (glen herrmannsfeldt) (2008-03-03)
Re: silly question: prefix vs postfix ops haberg_20080207@math.su.se (Hans Aberg) (2008-03-03)
Re: silly question: prefix vs postfix ops marcov@stack.nl (Marco van de Voort) (2008-03-03)
Re: silly question: prefix vs postfix ops gah@ugcs.caltech.edu (glen herrmannsfeldt) (2008-03-04)
Re: silly question: prefix vs postfix ops dot@dotat.at (Tony Finch) (2008-03-04)
Re: silly question: prefix vs postfix ops rpboland@gmail.com (Ralph Boland) (2008-03-04)
Re: silly question: prefix vs postfix ops alexc@TheWorld.com (Alex Colvin) (2008-03-05)
Re: silly question: prefix vs postfix ops DrDiettrich1@aol.com (Hans-Peter Diettrich) (2008-03-06)
| List of all articles for this month |

From: Ralph Boland <rpboland@gmail.com>
Newsgroups: comp.compilers
Date: Tue, 4 Mar 2008 17:59:29 -0800 (PST)
Organization: Compilers Central
References: 08-03-012
Keywords: design
Posted-Date: 04 Mar 2008 22:31:36 EST

On Mar 3, 11:37 am, MattR <ros...@peakfive.com> wrote:
> This is more of a language question than a compiler question (and
> therefore should create a religious battle :) ), but I'm wondering if
> the answer has more to do with the compiler. Anyway, why are there
> prefix operators that could just as well be postfix? Why is it !a and
> not a!, or *a and not a* ? I can understand the increment and
> decrement operators, and the & op but expressions like *a[i] would be
> a lot clearer if it were a[i]*, just read the operators from right to
> left. Is it a case of, well, it's always been done this way?
>
> [We've always done it that way. -John]


Not of great importance but, since this is compilers, I hasten to
point out that it is easier to parse/build abstract syntax trees if
prefix unary operators are used. This is because, for example, the
negate operation is above the thing it operates on in the abstract
syntax tree. so parsing can proceed top down. Of course, if you're
designing a language, this is NOT a good reason to use prefix unary
operators.


Ralph Boland


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.