Topic: Proposal: Strongly Typed Logical Oper


Author: Richard Kaiser <mail_d1@rkaiser.de>
Date: 3 Apr 2005 20:45:02 GMT
Raw View
Current Boolean operators    and   ,    or    and    not    (like &&, || and !) are
not type-safe. Since their operands are subject to integral promotions,
expressions like

 int i; bool b;
 if (b and i) ...
 if (b or i) ...
 if (not i) ...

are valid, although they may not be intended. Such errors could be
detected by the compiler, if the operands of    and   ,    or    and    not    would
be required to be of type bool. Integral promotion for the operands of
the traditional operators &&, || and ! should remain the same.

Since the alternative tokens    and   ,    or    and    not    are not widely used,
there would be not many conflicts for existing programs. All these
conflicts could be resolved by using the traditional operators &&, || and !.

Richard Kaiser

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]