Re: Set the CheckBox.Checked without the OnClick being called



Maarten Wiltink wrote:

Why couldn't we just have one universal standard for a boolean,
whereby 1 is true and 0 is false? Isn't that a hell of a lot simpler?


'Standards are wonderful. So many to choose from.'

As was explained in another post, there are also sound reasons to use
(-1) for true. There are disadvantages to that, too, most importantly
that comparing the underlying values as integers will result in True
being less than False.

In an unsigned interpretation, False <= X <= True will hold.

Such systems typically have only one set of boolean operators, working bitwise on integral values, and have no special boolean type. The value of True is the consequence from
True == not False
and
X and True == X

A signed True value of -1 will expand to whatever operand size is used, by propagation of the sign bit, in contrast to any unsigned value, which would be extended with zeroes.


It gets worse. When using an integer as a status code, zero means
'success' and any other value means 'failure'. Because there's only
one way for things to work right, but endless ways for them to go
wrong.

That's why the Windows API's typically use Integer results, not boolean ones - at least this was the original paradigm. The requirement for the LongBool etc. Delphi data types comes from pseudo-boolean C subroutine arguments, where the caller expects the value encoded in a certain number of bytes, whereas a Delphi "boolean" would be passed only as a single byte[1]. I wonder why the use of those pseudo-boolean types is not restricted to the use with arguments of external subroutines - adding implicit conversion to true boolean types and values, in expressions, IMO was a bad decision.

[1] The requirement of a fixed argument size also might be the reason, why we don't have true enums or sets for some of the API function arguments. Explicitly sized enums and sets really would be a nice feature, for API or other C interfaces.


Another possibility is the time I was confused by someone (a
mathematician, I have no doubt) who represented False by 1 and True
by... 2. The entire book started counting enumerations at one. It
was somewhat trying.

This also might be related to array indexing, where Basics frequently start with 1, unless they allow for an "Option Base 0". The same legacy exception with Delphi strings, whose first character have the index 1. A StringBase option had been nice, introduced together with dynamic strings and {$HugeStrings+}.

DoDi
.



Relevant Pages

  • Re: Copying Similar Data Structures
    ... Since all my strings are fixed-length, do I need the SAFEARRAY stuff? ... I tried using a straight CopyMemory call and it seemed to work great. ... When finished I have array of new structure to write back to disk. ... > WeekOKAs Boolean ...
    (microsoft.public.vb.general.discussion)
  • Re: Declaring types for properties redundant ?!!
    ... I was just thinking to myself: "Gje that Delphi doesn't understand that;)" ... property SomeProperty read mSomeField write mSomeField; ... procedure setActive (newActive: boolean); ... If you want those same features, but without the requirement to declare types, then use OCaml. ...
    (alt.comp.lang.borland-delphi)
  • Re: Cant load gdiplus dynamically
    ... Even delphi will do that when testing values that are from non constants or not compiled generated just in case the TRUE value is ... Delphi uses 1 when setting a boolean to true ... If you where using a Callback function and SuppressBackgroundThread was True, you would pass a wrong pointer to GdiplusStartup. ... Only because everything behind GdiplusVersion is 0 in my app, ...
    (alt.comp.lang.borland-delphi)
  • Re: Cant load gdiplus dynamically
    ... Even delphi will do that when testing values that are from non constants or not compiled generated just in case the TRUE value is ... Delphi uses 1 when setting a boolean to true ... If you where using a Callback function and SuppressBackgroundThread was True, you would pass a wrong pointer to GdiplusStartup. ... Cut boolean down to 1 byte as I did, and you will run into even more problems with a packed record. ...
    (alt.comp.lang.borland-delphi)
  • Re: The lack of a boolean data type in C
    ... KA> That it makes sense to have a boolean type? ... not equal to zero. ... integral types in the first place, or map to the extracting-bits approach. ... the benefit you get from a pure Boolean type is nonexistent. ...
    (comp.lang.c)