I suspect this is an inheritance from VB's humble beginnings.
As others have already pointed out in this thread, VB also overloads the
And, Or, Xor, and Not operators. They can each be used in a "bitwise"
context, e.g.
x = y And z
or a "logical" context, e.g.
If x<0 Or Y<0 Then
The reason is related to the overloading of the '=' operator. Very simple
languages (as Basic was), especially those that are interpreted, reduce
their complexity by handling conditional expressions using exactly the same
expression analyser as arithmetic expressions, and using a stack-based
evaluator for both [Huh?].
For instance, the above 'If' statement might be evaluated as follows:
push x ' push x on evaluation stack
push 0 ' push 0
test_lt ' compare top 2 elements, and replace by a boolean
push y
push 0
test_lt
or ' combine top 2 elements using bitwise 'Or'
Note that the evaluation uses only bitwise operations. The compiler (or
interpreter) doesn't need to worry about coding jumps, or short-circuiting
evaluation.
This is also the reason why 'True' in VB has the value -1, and not 1 as in
C/C++. Otherwise, the following would not be correct:
False = Not True
Tony Proctor
John Davis said:
One interesting observation I found is VB6 or VB.NET overloads = opeartor.
i.e. = operator has 2 meanings.
Case 1: relational operator. In other languages, usually use == instead.
If a = b Then statement
Case 2: assignment operator
a = b
Just my observation. Please discuss.