using less stack

Richard Uhtenwoldt
Sun, 24 Mar 2002 12:23:23 -0800

Hal Daume III writes:

>> You don't have to define cpsfold explicitly recursively since it can be
>> expressed in terms of foldr:
>Is this generally considered good design?  That is, is it generally
>preferred to express functions in a nonrecursive style if that can be done
>using standard library functions like foldr and map and filter,

One answer that Alastair Reid did not mention is that the nonrecursive
style usually benefits from the deforestation optimization whereas
IIUC the explicitly recursive style never does in contemporary

Another answer, which I give because the factor does not enter enough
into the thinking of academic language designers, is that the
nonrecursive style inhibits adoption of Haskell by making it slightly
more difficult for the average programmer or programmer-wannabe to
learn --"slightly" because with recursion, lists and monadic
interfaces Haskell already has a lot of significant learning barriers
to adoption, and the nonrecursive style of definition is easier to
learn (get used to) than any one of those last 3.

Richard Uhtenwoldt