Re: silly question: prefix vs postfix ops

Hans Aberg <haberg_20080207@math.su.se>
Mon, 03 Mar 2008 22:10:19 +0100

          From comp.compilers

Related articles
silly question: prefix vs postfix ops rosing@peakfive.com (MattR) (2008-03-03)
Re: silly question: prefix vs postfix ops csaavedra@alumnos.utalca.cl (Claudio Saavedra) (2008-03-03)
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: Hans Aberg <haberg_20080207@math.su.se>
Newsgroups: comp.compilers
Date: Mon, 03 Mar 2008 22:10:19 +0100
Organization: Aioe.org NNTP Server
References: 08-03-012
Keywords: syntax, design
Posted-Date: 03 Mar 2008 16:19:10 EST

MattR 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?


In the Lukasiewicz notation, all operators are prefix. This is used
in proof theory, for example Shoenfield, "Mathematical Logic". The
postfix notation was invented later - it is particularly easy to
implement with stacks.
      http://en.wikipedia.org/wiki/Polish_notation
      http://en.wikipedia.org/wiki/Reverse_Polish_notation


So today, it is just a notational convention. Mixing in the same
language, may cause ambiguities. This happens for example in music, when
writing chords like A#7. Here, for some reason one may like to write A#
and #7. So some disambiguation is needed if the operator order is to be
kept: parenthesizes, superscripts, or something.


      Hans Aberg


Post a followup to this message

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