#94371 - 2002-11-01 08:26 PM
Re: RFC - Hungarian Notation for KiXtart & KiXforms - Discussion
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
I agree Erik, anything that is NOT 0 is true.
FYI with COM, its generally recognized that when forced to specify a value for TRUE, everyone uses -1. Its interesting to note however that when Kixtart evaluates NOT 0, it returns a 1 (which to my mind, is intuitively a better TRUE than -1 is) and I think why this situation occured has more to with with the history and legacy of Kixtart more than anything else, even though the NOT operator was added late in the game (not sure really).
I know that we're talking around isoteric issues here, but does it make sense to leave FALSE as an unspecified value that is NOT 0 ? Im cool with it because I tend to pratice poor coding habits anyways. Break more rules than I follow thats to be sure. The question really becomes, is a statement like this best pratice:
code:
if $bFlag ; then do something true else ; do something else false endif
because that would be the impact of leaving boolean TRUE as un-specified. From what I've seen around this board, this kind of opened-ended if statement expression is frowned upon, fe: the best pratice version of above ?
code:
if $bFlag = 1 ; then do something true else ; do something else false endif
[edit]
lol - heres a quasi best practice variant:
code:
if not not $bFlag ?"true" endif
I need some coffee. [ 01. November 2002, 20:32: Message edited by: Shawn ]
|
Top
|
|
|
|
#94373 - 2002-11-01 09:04 PM
Re: RFC - Hungarian Notation for KiXtart & KiXforms - Discussion
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
yap - INSTR() is a perfect example of why NOT 0 is a great definition of TRUE. Maybe great is NOT a good word ... usefull would be a better word. I guess it could also be coded as:
code:
if instr("abc","b") > 0 ; ... endif
all the more reason why I think a 1 is more TRUE than -1 is. And even more reason why Ruud should build TRUE and FALSE into the language (just like almost every other language one can name) ala: @TRUE and @FALSE macros. I mean, when coding a UDF that returns a boolean, wouldn't it be more convenient (and standardized) if we could just say this:
code:
return @TRUE
Then for those that like to code both sides of the expression, they can just say this:
code:
if $rs = @TRUE ; ... endif
[ 01. November 2002, 21:09: Message edited by: Shawn ]
|
Top
|
|
|
|
#94374 - 2002-11-01 09:19 PM
Re: RFC - Hungarian Notation for KiXtart & KiXforms - Discussion
|
kholm
Korg Regular
   
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
There is 10 kinds of people that understands binary code.
Should that be: There is -10 kinds of people that understands binary code. ???
I miss that sig.
-Erik
No overrun if you convert it, Using CDBL()
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1574 anonymous users online.
|
|
|