Re: Question about Delphi versus other languages
From: VBDis (vbdis_at_aol.com)
Date: 10/18/04
- Next message: Bruce Roberts: "Re: object count"
- Previous message: VBDis: "Re: Question about Delphi versus other languages"
- In reply to: Sven Pran: "Re: Question about Delphi versus other languages"
- Next in thread: L D Blake: "Re: Question about Delphi versus other languages"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 18 Oct 2004 15:24:37 GMT
Im Artikel <BaCcd.2533$rh1.72183@news2.e.nsc.no>, "Sven Pran"
<no.direct@mail.please> schreibt:
>And please remember that the internal data format for boolean variables
>implemented in byte, word or longword fields defines the available values:
>
>0 as false and any nonzero value as true.
Please note that these types are different from the predefined "Boolean" type.
The Boolean and ByteBool as well as the Char type happen to be stored in bytes,
but nonetheless they are very distinct data types.
>This means that ordinal values greater than one are not undefined nor
>are they illegal. They are just "true" (all of them).
This is true when such almost-boolean values must be converted into an Boolean
value. Unfortunately Borland decided that such values are converted silently
into boolean whenever required, causing your confusion about the really-Boolean
and almost-boolean types.
An implicit conversion of almost-boolean types can occur in boolean
expressions:
if x then
but a comparison
if x = y then
compares the ordinal values of the almost-boolean types, without converting
them into Boolean before.
I'd treat WordBool etc. just like Variant, i.e. types that can show an
unexpected behaviour. Use them at your own risk!
Another source of confusion are the logical operators, that can work bitwise as
well as logical. Other languages have different operators for these different
purposes, like "&" and "&&" in C. Unless both operands are really Boolean, the
Delphi logical operators work bitwise, not logical!
DoDi
- Next message: Bruce Roberts: "Re: object count"
- Previous message: VBDis: "Re: Question about Delphi versus other languages"
- In reply to: Sven Pran: "Re: Question about Delphi versus other languages"
- Next in thread: L D Blake: "Re: Question about Delphi versus other languages"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|