> But in C or Java, you will never get any integer value as a
> result of a boolean _expression_, you will always get 0 or 1 (or -1)
Actually, in Java, using an integer in a boolean context throws a compile
time error. I believe you can use an explicit cast to get around it, but
I'm not sure. Even if you can, it's definitely bad style. And the result
of any boolean _expression_ is either true of false, never a number.
In C, you can use numbers as booleans, but that's because C doesn't have
knowledge of a boolean type. On the processor, there is only numeric types,
and when a decision is being made, zero is false, anything else is true.
With C, there is no disguising of that fact between the processor hardware
and the language. With CF, on the other hand, Java intentionally hides that
in the boolean type to aid the developer, and then CF intentionally removes
the restriction as part of the language. In other words, '1' in C
translates directly to a yes on an OR gate, while a '1' in CF is translated
by the Java runtime as a Java 'true' on an as needed basis, and then
translated to a yes on a OR gate by the JVM.
Cheers,
barneyb
> -----Original Message-----
> From: Claude Schneegans [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 20, 2004 3:35 PM
> To: CF-Talk
> Subject: Re: Is it a bug or not a bug?
>
> >>In a loosely typed language (which CF is), 20 IS true. There is NO
> DIFFERENCE.
>
> A loosely typed laguages means that values may be
> automatically converted as needed, it does not mean that they
> all are the same. 20 is NOT true: 20 is converted to true if
> one looks at it as a boolean value.
>
> >>by CF has no concept of boolean vs.
> integer. This is a trait of loosely typed languages.
>
> Not exacltly, there is no difference either in C, Java, etc.
> But in C or Java, you will never get any integer value as a
> result of a boolean _expression_, you will always get 0 or 1 (or -1)
>
> --
> _______________________________________
> See some cool custom tags here:
> http://www.contentbox.com/claude/customtags/tagstore.cfm
> Please send any spam to this address: [EMAIL PROTECTED]
> Thanks.
>
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

