Simon Strandgaard wrote:
Then it would be easy to add a Maybe class
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.