> I'm nervous about these different contexts.  I thought scalar vs list
   > was confusion enough.  Now we're talking about overloading even
   > further?  We need to think VERY long and VERY hard about this before
   > thinking it's a good thing.

Well, I have, and I do.
(Though I'm no longer sure whether that's an argument for or against! ;-)

The problem is not multiple contexts; it's inconsistent return values.
That is, there's no way of guessing what a particular "listish" function
-- such as map, each, reverse, etc. -- will return in a scalar context,
without actually *knowing* what it's defined to return).

In some senses additional contexts actually help, by improving DWIMity.

If I can say:

        my $month = date->{month};

then I'm much more confident what I'm going to get back. As opposed to:

        my $what = date;

which might return epoch seconds as an integer, or a date string, or a
hash- or array ref, or the number of elements in the date array :-(

With extra contexts I can be surer:

        my $yesterday = date() - 86400;     # reasonable to expect epoch integer
        my $today = "today is " . date();   # reasonable to expect date string
        my $tomorrow = date()->{DoY} + 1;   # reasonable to expect hash ref

Damian

Reply via email to