IF Boolean_Logic = Inconsistent Then IsBug()

BlitzMax Forums/BlitzMax Programming/IF Boolean_Logic = Inconsistent Then IsBug()

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

"Ints are not being converted to booleans"

Not in the compiler AS IT IS, no.

But it would be something that could be done at compile time, just as with any other type conversion which is dissalowed. If BlitzMax had a boolean type. Which it does not. But that doesn't mean it would be a bad idea to have one.

"Because no-one has created a computer that can read your mind yet. A computer will do what you tell it to, not what you think you tell it to."

Flameduck, are you intentionally being difficult or what?

There's no mind reading that needs go on here.


If I can do the following:

Function Blah(X:Boolean)

And get an error "cannot convert from int to boolean" when I pass it an int, then the same could be done for an IF statement.

There's no mind reading required.

10 > 5 is a boolean expression and would be evaluated as such, and converted to a boolean type, then passed to the if statement.

10 is not a boolean expression. It is just an integer. There is no > operator to cause it to be converted to a boolean type internally.

So If 10 would error, and 10 10 > 5 would not.

So show me an example where the compiler would need to guess. The compiler doesn't need to guess when you write 10 / 1.5. It converts to a float. This is the same thing.

In fact, if I'm not mistaken someone mentioned C# doing something like this. If that is the case then you're clearly wrong and it is not impossible or would require the compiler to guess.