A goto-like usage of a function

Remi Turk rturk at science.uva.nl
Fri Jul 30 00:30:10 CEST 2004

On Thu, Jul 29, 2004 at 01:31:19PM -0700, Donn Cave wrote:
> Depends of course on the language, but there sure exist
> languages where "while" and "for" don't even exist (and
> hence are not conventional control structures.)  Haskell
> is the one I know.
> That isn't an accident, they aren't omitted just because
> no one had time to implement them.  Loops are an "imperative"
> construct that doesn't make sense in a pure functional
> language like Haskell.  So I suppose that even where there's
> more support for imperative constructs, as I think there is
> in Scheme for example, a mature programmer of a Functional
> Programming persuasion might well on the contrary recode
> a loop to a recursive algorithm.

Except that as general recursion is in some aspects quite a bit
like goto (power, readability etc), it is often preferred to
refactor the recursion into it's own function: Higher-order
functions like map, filter and reduce/fold. Which means that,
in some ways, a language like Haskell _does_ have control
structures (which are preferred over recursion),
although those structures happen to also be functions.
(I've (re)cursed (in) Prolog at college far too much,
so I may be overreacting against explicit recursion <wink>

Happy hacking,

Nobody can be exactly like me. Even I have trouble doing it.

More information about the Python-list mailing list