[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Left- and right-ness of folds
> Bradd W. Szonye wrote:
>> Even with the "right-associative" definition, a right fold is still
>> not possible for an infinite sequence, because the fold will not
>> halt. It will diverge before you can even use the initial value. You
>> first need to select a finite subset so that you can apply the
>> initial value in the fold.
> It would still be defined for said collections however. The fact that
> it may not halt is a pitfall for the programmer that attempts it.
That's a big pitfall! A right-fold on an infinite sequence will diverge
before the folding function ever gets called. I think it's a bad idea to
provide an interface that is "broken by design" like that -- it cannot
possibly function correctly.
It's one thing to include dangerous procedures, stuff that will blow up
if you don't use it correctly. But it's another thing to include
procedures that cannot possibly work. I realize that Scheme has a very
"academic" following that worries more about concepts than practical
matters. However, this SRFI seems to take that to an extreme! The design
principles seem to include, "No matter how error-prone an interface is,
it's still the programmer's fault for misusing it," and "Incompatibility
with prior art is unimportant." While that might fly in some academic
contexts, it's *horrible* from an engineering point of view.
Bradd W. Szonye