Re: Overloaded logic operators

Hans Aberg <>
Thu, 04 Dec 2008 20:44:52 +0100

          From comp.compilers

Related articles
[11 earlier articles]
Re: Overloaded logic operators (Bartc) (2008-11-25)
Re: Overloaded logic operators (Chris Dodd) (2008-11-25)
Re: Overloaded logic operators (2008-11-26)
Re: Overloaded logic operators (Frank Swarbrick) (2008-11-27)
Re: Overloaded logic operators (Tony Finch) (2008-12-01)
Re: Overloaded logic operators (Alex Colvin) (2008-12-03)
Re: Overloaded logic operators (Hans Aberg) (2008-12-04)
| List of all articles for this month |

From: Hans Aberg <>
Newsgroups: comp.compilers
Date: Thu, 04 Dec 2008 20:44:52 +0100
Organization: NNTP Server
References: 08-11-110
Keywords: syntax, design
Posted-Date: 04 Dec 2008 15:07:11 EST

Mike Austin wrote:
> In many languages, logic operators "and" and "or" have been overloaded to
> handle more than booleans.
  > I'm torn between this being easier for the programmer, or just bad
  > practice in general.

It is not the operator overloading that is causing problems, but
implicit type conversions, especially in the case where it loses some
information. The problem is that the effects of such syntax is hard to
detect when debugging.

So, for example, converting (multiprecision) integers to rational
numbers is safe, but converting rational numbers to floats might cause
some unexpected things: unequal numbers may be treated as equal, for
example. Converting floating point numbers implicitly to integers is
bad, because such conversions may need some guards against round-off

  > In languages such as Ruby, Lua, Io, Python and JavaScript, does the
  > benefit outweigh the effect of overloaded logic?

One such example is C, where it was problematic in C++, wanting to keep
the C syntax.


Post a followup to this message

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