develooper Front page | perl.perl6.language | Postings from June 2005

Re: reduce metaoperator on an empty list

Thread Previous | Thread Next
Deborah Pickett
June 1, 2005 17:19
Re: reduce metaoperator on an empty list
Message ID:
On Wed, 1 Jun 2005 19.37, Damian Conway wrote:
> Deborah Pickett wrote:
> > Someone please convince me otherwise.
> So what you want is not an identity value as default (which isn't even
> possible for many operators, as Luke pointed out), but a predictable
> failure value as default, so you can intercept that failure and choose your
> own outcome in the edge case.

You haven't convinced me, but rather than flog a dead horse, I'll just suggest 
that we both reserve the right to say "I told you so" when there are several 
years' worth of Perl 6 code out there, and we see how common our respective 
examples are.  Meanwhile, it's safer to take the "fail" course of action, 
because it can be relaxed later on; the converse couldn't be true.

What you and Luke *have* convinced me of is that the one-element list rule 
isn't right either; for operators like <, it still makes sense to fail in 
some soft way on one-element lists:
  $ordered = ([<] @array) // 1;      # Zero- and one-element arrays get the 1.
I'm starting to agree that there have to be different rules for associative* 
and non-associative reduction.

* Left and right association might need to be different too in terms of the 
order they eat list elements.

Debbie Pickett

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About