On Fri, 3 Dec 2010, Sean Conner wrote:
It was thus said that the Great Philip Pemberton once
stated:
Really? His posting is missing in cctalk...
> On Fri, 2010-12-03 at 11:32 +0100, Christian Corti
wrote:
>> On Fri, 3 Dec 2010, Kevin Schoedel wrote:
>>> Also,
>>> "TF"[!b]
>>
>> This is a great example!
>> Now let's guess why this works, but not "FT"[b]
>
[...]
> So you use the unary negation operator, which
turns your 0x80 (true)
> into 0 (false). "TF"[0] is "T", because the original value was
true.
> Similarly, !0 = 1, and "TF"[1] is "F".
Right.
> 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 dependent,
Indeed, it's compiler dependent.
Of course, there's always "FT"[!!b]
This doesn't change much because !!123 may still be 123 instead of 1.
Christian