On Mon, 6 Dec 2010, Brent Hilpert wrote:
It was thus said that the Great Philip Pemberton once
stated:
[...]
> However: the compiler would still be correct
to use the value 123
> instead of 1, thus that code may not work... So it's compiler
!!-1 =
!(!-1) = !(0) = 123
!!123 = !(!123) = !(0) = 123
!!0 = !(!0) = !(123) = 0
Whether that's correct behaviour or not was not the question.
Lame. It was the question.
No, it was stated by Sean Conner that if a (admittedly broken)
compiler used a value of 123 for !0, you could circumvent this
behaviour with a double negation, i.e. !!(!0) would produce a 1.
That's what he said:
Nope. !b will turn 0 to 1, and anything not 0
to 0.
!!-1 = !(!-1) = !(0) = 1
!!123 = !(!123) = !(0) = 1
!!0 = !(!0) = !(1) = 0
which is clearly not the case if you assume a broken compiler that
doesn't evaluate !(0) to 1. I think I have seen such a compiler (maybe
a
cheap PD compiler on the Amiga, but I'm not sure), so it may well be
compiler dependent (although not correct and I've never questioned
that).
Is it possible that we are talking past each other?
In the same sense that anything is possible if a compiler can do
anything it wants regardless of the language definition, I guess it is.
Agreed that double negation is not a fix to the error of said broken
compiler, but I wasn't sure that was Sean's point in suggesting double
negation.
You nonetheless agreed with Phil's assertion that it was
compiler-dependant behaviour.