Re: 1 or 1/0 doesn't raise an exception



Rohannes wrote:
'Dive into Python' has a very memorable and interesting section on the
exact behaviour of 'and' and 'or' in Python:

http://diveintopython.org/power_of_introspection/and_or.html

No: &, | (and ^, too) perform bitwise operations in Python, C and Java:

"In complete evaluation ... both expressions are always evaluated. To
obtain complete evaluation in Java, you use & rather than && ... and
use | in place of ||" - Walter Savitch, Absolute Java 2nd ed.

Although & IS the bitwise-AND operator in Java:
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html

I guess it's a matter of context.

Java has a bool type that's distinct from the int type. &, | and ^ are bitwise for int and Boolean for bool, and in both cases they are strict. && and || are for bool only and they are lazy.

In Pascal the behaviour of "and" and "or" is implementation-dependant...
.



Relevant Pages

  • Re: Java outperforms C++?
    ... I didn't know that bool was so inefficient ... What we have is still really transliterated Java. ... directly instead of using the base class method to do so, ...
    (microsoft.public.vc.language)
  • Re: Precedence of &, ^, |, &&, II
    ... >You are confusing operator precedence and order of evaluation. ... In Java, ... = is to the left of the expression the assignment, ... first computer languages, you would be writing Java like this, the way ...
    (comp.lang.java.help)
  • Re: While-loop not listening to conditions
    ... be different for different compilers or possibly even different ... In Java, expression trees are generally evaluated in the order "lhs, ... It is comforting to know how these statements parse, ... precedence and order of evaluation are among the most fundamental ...
    (comp.lang.java.programmer)
  • Re: Plz explain me the following code
    ... of times on HLL languages, where such constructions ... and I don't know Java well enough to comment on ... The Java programming language guarantees that the operands of operators appear to be evaluated in a specific evaluation order, namely, from left to right. ...
    (comp.lang.c)
  • Re: using matlab compiled dll without java support
    ... And i want to initalize the MCR without using java support, so I am doing the following: ... So it seems that java is loaded after all, and the plot window is sun window although I am initalizing with -nojvm. ... bool mclInitializeApplication; ...
    (comp.soft-sys.matlab)