Parent of TrueClass, FalseClass, continued

Simon Strandgaard wrote:

Then it would be easy to add a Maybe class :wink:

You’re joking a little, I know, but consider the case of Oracle.
Well, ok, Oracle PL/SQL. In Ruby, nil is false. However, in Oracle
PL/SQL you have a Boolean data type that is either true, false or null
(i.e. unknown).

Having a Boolean parent class could make object-relational mapping
layer packages, like Kansas, a bit easier (though I admit, I’m
guessing here). It could also be useful in DBI itself, where I could
retrieve data from a column with a NULL value as nil, but which
wouldn’t equate to false. From there I can perform tri-state code
logic, ala PL/SQL.

For example, consider a table with a VARCHAR2(1) column called
“is_deceased” for a list of movie actors and actresses. I could
either have ‘Y’ or ‘N’ to indicate true or false. But if there’s no
constraint on that column it could also be NULL, which is NOT the
same as false. See what I mean?

It could also be handy for that magical day when someone finally gets
around to embedding Ruby within Oracle, ala the PL/SQL Ruby module
that already exists for Postgres, or extproc_perl for Oracle.

As someone else already mentioned, it can also make unit testing
either. Instead of “is this value true or is this value false”, I can
perform this operation as one “is this value a boolean”. That, again,
may be useful in the database side of things.

Well, that’s all I can think of for now. Maybe some other folks could
provide additional examples where it would be useful.

Just my .02

Regards,

Dan

PS - Damn - google groups doesn’t seem to be picking up the ML traffic
again, so I’ve had to create a new thread since I don’t subscribe to
the ML. My apologies.

Heh. I skipped a lot of the middle of this thread. Now I am going to
have to go back and read it all. I can see for my own use where exactly
what you describe would be very useful. I have code right now that deals
with precisely what you describe, with a 1 char field that can be ‘y’ or
‘n’ or null.

I like the way that you think, Mr. Berger. I’m glad I decided to read
what you had to say. :slight_smile:

Thanks,

Kirk Haines

···

On Sat, 3 Apr 2004, Daniel Berger wrote:

You’re joking a little, I know, but consider the case of Oracle.
Well, ok, Oracle PL/SQL. In Ruby, nil is false. However, in Oracle
PL/SQL you have a Boolean data type that is either true, false or null
(i.e. unknown).

Having a Boolean parent class could make object-relational mapping
layer packages, like Kansas, a bit easier (though I admit, I’m
guessing here). It could also be useful in DBI itself, where I could
retrieve data from a column with a NULL value as nil, but which
wouldn’t equate to false. From there I can perform tri-state code
logic, ala PL/SQL.

For example, consider a table with a VARCHAR2(1) column called
“is_deceased” for a list of movie actors and actresses. I could
either have ‘Y’ or ‘N’ to indicate true or false. But if there’s no
constraint on that column it could also be NULL, which is NOT the
same as false. See what I mean?