Java’s Broken Booleans

  • Thread starter Lawrence D'Oliveiro
  • Start date
A

Arved Sandstrom

bugbear said:
Remind me: who didn't like "pure" booleans, and wanted
them usable as array indexes... ?

BugBear

Or more fundamentally, who is insisting on an numerical{0, 1} representation
of Boolean variables? Who, while tossing around terms like Boolean algebra,
is more comfortable with a C or BASIC type language where "false" is the
number 0 and "true" is 1 or -1, or various permutations thereof? Who has
come out with pronouncements about the behaviour of "every" language he
knows...which clearly isn't a lot?

I'm still wrapping my head around the fact that he can casually imply
knowledge of Galois theory, all while being unable to move past a concrete
numerical representation of a Boolean domain. Given that I think it's pretty
safe to assume that by Boolean algebra he means Boolean logic in computer
science, which he's obviously still reading up on.

AHS
 
L

Lew

So at least you finally admit the *existence* of a natural order ;-)
(getting the sequence right will be the next task, next year, perhaps)

Right, and I would /never/ have done so sarcastically!

Nor even to do a proof by contradiction.

Of course the "natural order" exists - given a particular definition of
"natural" and "order". You offered one that was "natural" in your private
universe. It isn't absolute, and it's only "natural" to the degree you say,
given that it's your order. I don't dispute that, really, only that such an
order is equally "natural" or even an actual "order" for anyone but yourself.

On that note I'll let this subthread sleep until the next post.
 
L

Lew

Arved said:
I'm still wrapping my head around the fact that he can casually imply
knowledge of Galois theory, all while being unable to move past a concrete
numerical representation of a Boolean domain. Given that I think it's pretty
safe to assume that by Boolean algebra he means Boolean logic in computer
science, which he's obviously still reading up on.

It is far from obvious to me that he's reading up on anything.
 
D

Daniele Futtorovic

Right, and I would /never/ have done so sarcastically!

Nor even to do a proof by contradiction.

Of course the "natural order" exists - given a particular definition of
"natural" and "order". You offered one that was "natural" in your
private universe. It isn't absolute, and it's only "natural" to the
degree you say, given that it's your order. I don't dispute that,
really, only that such an order is equally "natural" or even an actual
"order" for anyone but yourself.

It should be fairly obvious that any ordering of boolean values would
be, at the same time, true and false or false and true.

If that isn't a reductio ad absurdum, I don't know what is.

;o)
 
A

Andreas Leitgeb

Daniele Futtorovic said:
[...] I don't dispute that, really, only that such an
order is [...] even an actual "order" for anyone but
yourself.

I think, I'll listen to you some more - it's funny.
It should be fairly obvious that any ordering of boolean values would
be, at the same time, true and false or false and true.

I fail to parse the logic behind the addition of "at the same time",
but that's probably, because there isn't one.
and that may explain it.
 
A

Arne Vajhøj

Nonsense. A truth is "naturally" worth more than a lie.

It is not quite clear to me whether you are joking or not.

true/false has nothing to do with truth and lie.

Look at a typical boolean:

private boolean modified;

It describes whether some data are modified or not. That
data are modified are not truth and that data are not modified
is not lie.

Arne
 
A

Arne Vajhøj

Here's one: COBOL. Level-88 items let you define the representation of
"true" and "false" for a given variable, so they can have any ordering
you like.

But, hey, it's only the second-oldest HLL still in widespread use,
with millions of SLOC in existence. Can't really expect a Usenet
self-anointed programming-language expert like Lawrence to have heard
of it.

It is usually estimated to around 200-300 billion LOC.

Arne
 
A

Arne Vajhøj

If modified is false, then it is a lie to claim it is "modified".

But it is not claiming that it is modified, if modified is false then
it is claiming the opposite.

Arne
 
A

Andreas Leitgeb

Arne Vajhøj said:
But it is not claiming that it is modified, if modified is false then
it is claiming the opposite.

Afaict, the name of that variable isn't changed. Setting it to
false doesn't change it to a variable "unmodified" holding "true". :)

So, depending on the value, the fixed claim "it is modified" is
either meant to be true or wrong. A wrong claim of being modified
can of course be seen as a claim of being "unmodified", but
that is just interpretation, not the original data.

Alternatively, one could make an enum with constants MODIFIED and
UNMODIFIED, and use a thusly typed variable "state" instead of the
boolean.
 
L

Lawrence D'Oliveiro

bugbear said:
Remind me: who didn't like "pure" booleans, and wanted
them usable as array indexes... ?

Which side of the argument are you trying to hold up, exactly?
 
L

Lawrence D'Oliveiro

The problem is not in the compiler, but in the programmer
using the keyboard.

Read and fix your code, then it will work.

But Mr Duniho claims that Java does “just as I wishâ€, while you are saying
what I wish is wrong. Who is right?
 
L

Lawrence D'Oliveiro

"false" is 0, and "true" is any non-zero number, so it's clear that true
is both smaller than and greater than false.

I’m not really fond of that interpretation. I prefer a specific value for
“trueâ€. There are often pitfalls in different languages where values other
than 0 can be equivalent to false, much to the programmer’s surprise.
 
L

Lawrence D'Oliveiro

Instead, you propose to replace the statement !A || B with a statement
that is nearly the same effect...

In what way is it not exactly the same effect?
, but implies that the values are themselves integral entities as opposed
to elements of a finite simple group of order two.

It’s just modulo arithmetic, nothing more
Sometimes I do, if I really want to emphasize the true part.

But face it; you're resorting to ad hominems now, which probably means
you have no argument left.

Note that I didn’t directly call you an ad-hominem, I just mentioned a
situation that many others besides myself would agree is just plain stupid.
I only asked if you did it, I didn’t even try to claim you did. You could
have kept your mouth shut and not admitted to doing this sort of thing, but
no, you had to speak up and fall right into it.
 
D

Daniele Futtorovic

I’m not really fond of that interpretation. I prefer a specific value
for “true”. There are often pitfalls in different languages where
values other than 0 can be equivalent to false, much to the
programmer’s surprise.

Yeah, you're right, these things suck. Tell you what -- how about we
created a new type with only two possible values to represent booleans?
 
D

Daniele Futtorovic

Which side of the argument are you trying to hold up, exactly?

Well, this is BugBear we're talking about, so it's gotta be the true
one. Or was it the false one? I can never remember. Which one comes
first again? It's the other one.
 
M

Mike Schilling

Lawrence D'Oliveiro said:
I’m not really fond of that interpretation. I prefer a specific value for
“trueâ€. There are often pitfalls in different languages where values other
than 0 can be equivalent to false, much to the programmer’s surprise.

One of my favorites in XPath where:

When strings are converted to boolean, the empty string becomes false and
all others becomes true.
Booleans converted to strings become either "true" or "false".

So boolean(string(false)) = true.
 
L

Lew


Well, Daniele, that's a really good idea. I'm surprised "Lawrence D'Oliveiro"
didn't think of it! (No, I'm not.)

These values would need keywords to identify them. Could we use, hm, oh, I
don't know, "Satan" and "G-D"? No? How about "true" and "false"
(respectively?), then?

We'd better make them incommensurate with 'int' though, or we're right back to
the problem we're trying to avoid.

(With apologies to Dana Carvey.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,197
Latest member
Sean29G025

Latest Threads

Top