Hi JC and David, Sorry I'm late here. Was out most of the week. I assume by "implicit boolean" that David means treating an int as a boolean when the the int could potentially contain a value other than 0 or 1? So if we have: int success; You feel the check against NSK_TRUE is needed, and using !success would potentially yield an incorrect evaluation of the "boolean". Well, if success is not 0 or 1, then let's say it is 2. You end up with 2 != NSK_TRUE, which evaluations true. Compared with !2 which evaluations false. So clearly there is a difference, but which would you consider correct in this case? I'd consider the false evaluation correct. If success is not 0, we want !success to be false. But if you compare against NSK_TRUE, the evaluation only ends up being false when success == 1. This doesn't seem right to me, so I would argue that "success != NSK_TRUE" is not only clumsy coding, but also gives the wrong result for values other than 0 or 1. In order to correct it, you would use "success == NSK_FALSE". But I don't understand the implicit boolean concern with !success when the value is suppose to always be 0 or 1. Where I would object to do something like this is with pointer types. Using !ptr is bad. "ptr == NULL" should be used. That being said, if JC prefers to clean this up at a later date as part of changing success to a bool, that's fine by mean also. thanks, Chris
|
- RFR (M) 8212959: Remove booleans from tests in vmTestbase JC Beyler
- Re: RFR (M) 8212959: Remove booleans from tests in vmTe... David Holmes
- Re: RFR (M) 8212959: Remove booleans from tests in ... David Holmes
- Re: RFR (M) 8212959: Remove booleans from tests... JC Beyler
- Re: RFR (M) 8212959: Remove booleans from t... David Holmes
- Re: RFR (M) 8212959: Remove booleans from t... Chris Plummer
- Re: RFR (M) 8212959: Remove booleans f... David Holmes
- Re: RFR (M) 8212959: Remove boolea... Chris Plummer
- Re: RFR (M) 8212959: Remove bo... David Holmes