On Fri, 6 Dec 2002, Damian Conway wrote:

> The selector block/closure would, naturally, be called in C<int> context
> each time, so (again, as Larry pointed out) a boolean function would
> naturally classify into two arrays. Though it might at first be a little
> counterintuitive to have to write:

OK, but I would assert that the false/true classification is going to be
the more common case, not "classify by index position", and that
furthermore there will be a lot of situations where the false/true value
may be any number, not just 1 or 0.

For example, suppose I want to separate a list of people into people who
have never donated money and those who have.  Assuming that each person
object has a donations property which is an array reference, I would want
to classify them in this manner:

  (@nevers, @donors) := classify($_->[donations]) @people;

According to the C<int> model, that would give me people who have donated
zero times, and people who have donated once, and the people who have
donated more than once would be lost.  Now, of course you can force the
dontations into a boolean context, but, frankly, I think If we force
people to always remember to force boolean context, just to preserve the
(IMHO) unusual case of classifying by integer, we're, on balance, making
more work for the world.

Ergo, I suggest we simply have a separate command for the false/true
situation:

  (@nevers, @donors) := falsetrue($_->[donations]) @people;

(Yes, "falsetrue" is a stupid name, please replace with something better.)


-miko


Miko O'Sullivan
Programmer Analyst
Rescue Mission of Roanoke


Reply via email to