[REBOL] Encouraging functional programming Re:(4)

1999-11-27 Thread erich

>My understanding was that tail recursion ( or its optimized implementation )
>gives a (properly written) recursive program the efficiency of an
>iterative program.

Yes, because such implementations avoid "real" recursion, i.e. when they
encounter tail recursive function calls they do not push some kind of
return address on a stack. Of course, such an implementation of tail
recursion is desirable, but it is iteration, in fact.

I just wanted to point out that recursion generally is not a benefit at
all. It is also no special sign of functional programming languages, you
can do recursion in most imperative languages as well. The good thing about
functional programming languages is merely the fact that symbols are
evaluated regardless wether they're bound to data or to a function. This
allows high level of data and functional abstraction without having to
extend the core language.

BTW, with trow and catch it should theoretically be possible to implement
multitasking. Does anybody know how the "evaluation loop" at top level of
REBOL works? (not that I want to implement multitasking, that's far beyond
my capabilities, I'm just curious...)

Greetings,

Erich





[REBOL] Encouraging functional programming Re:(2)

1999-11-26 Thread erich

>Was it Ingo who mentioned that tail recursion had been removed from the
>current REBOL implementation and asked when it would be returned? That
>should take care of the stack overflow problem. The problem is a result of
>an incomplete implementation of REBOL (missing tail recursion) and I don't
>think it makes a good argument regarding the degree to which REBOL supports
>functional programming.
>
>Elan

If I've comprehended that correctly, a good language should eliminate tail
recursion and replace it by iteration. This is a feature of most CommonLISP
systems and Scheme.

After all, recursion is more expensive than iteration and should be avoided
whenever possible, and its always possible if the function calls are proper
tail-recursive.

Greetings,

Erich