User defined precedence for user defined operators.

Derek M Jones <derek@knosof.co.uk>
15 Aug 2006 19:58:35 -0400

          From comp.compilers

Related articles
[5 earlier articles]
Re: anyone interested in decompilation gah@ugcs.caltech.edu (glen herrmannsfeldt) (2006-08-14)
User defined precedence for user defined operators. gah@ugcs.caltech.edu (glen herrmannsfeldt) (2006-08-14)
Re: User defined precedence for user defined operators. tommy.thorn@gmail.com (Tommy Thorn) (2006-08-15)
Re: User defined precedence for user defined operators. DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-08-15)
Re: User defined precedence for user defined operators. marcov@stack.nl (Marco van de Voort) (2006-08-15)
Re: User defined precedence for user defined operators. tmk@netvision.net.il (Michael Tiomkin) (2006-08-15)
User defined precedence for user defined operators. derek@knosof.co.uk (Derek M Jones) (2006-08-15)
Re: User defined precedence for user defined operators. torbenm@app-5.diku.dk (2006-08-18)
| List of all articles for this month |

From: Derek M Jones <derek@knosof.co.uk>
Newsgroups: comp.lang.fortran,comp.compilers
Date: 15 Aug 2006 19:58:35 -0400
Organization: Knowledge Software, Ltd
References: <1154507032.629515.108580@m79g2000cwm.googlegroups.com> 06-08-017 06-08-037 06-08-047 06-08-060 06-08-065 06-08-069
Keywords: Fortran, syntax, comment

Glen,


  > As far as I know, the languages that allow operator overloading
  > use the same precedence in all cases for each operator.


It depends what you mean by an operator. Algol 68 allowed people to
define an identifier to act like an operator. The following example
is copied from page 188 of "Informal introduction to Algol 68" by
Lindsey et al.


op min = (real a, b) real: (a < b | a | b),
        min = (int a, b) int: (a < b | a | b);


a := x min y;


Now the priority (what Algol 68 called precedence) of one of these
'operators' could be specified.


prio min = 9;


All of this could occur in nested blocks potentially resulting in the
case about which our moderator has lost neural connection to the
appropriate memories.


  > [I don't think I've ever seen a language where the operator precedence
  > depended on the types of the operands, and I hope I never do. -John]


What's the problem? Developer knowledge of operator precedence is so
bad it probably wouldn't make much difference.


http://www.knosof.co.uk/cbook/accu06.html
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd mailto:derek@knosof.co.uk
Applications Standards Conformance Testing http://www.knosof.co.uk
[Hey, that doesn't depend on the type, it's redefined from one block to
the next. But it still strikes me as a swell way to introduce bugs
that nobody can find. -John]


Post a followup to this message

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