Thank you.  That was exactly the information I needed.

I already knew that tail-recursive procedures usually
out-performed non-tail-recursive procedures because
linear iterative processes were usually more space-
and time-efficient than linear recursive processes,
but I had just wanted to know if there was a way to
write Oz procedures that computed linear recursive
processes similarly to the corresponding Scheme
procedures in SICP.  Your response answered my
question.

Cheers,

Ben

--- Raphael Collet <[EMAIL PROTECTED]> wrote:

> Benjamin L. Russell wrote:
> > Thank you; that makes sense.  So, if I understand
> > correctly, essentially, it's syntactic sugar for
> the
> > equivalent tail-recursive procedure.
> > 
> > But that brings up the question of whether I can
> make
> > a procedure explicitly non-tail-recursive.  E.g.,
> if
> > the following piece of code
> > 
> >>Z = X|{SMerge Xr Ys}
> > 
> > is always automatically converted to the following
> > piece of tail-recursive code
> > 
> >>local Temp  in
> >>  Z = X|Temp
> >>  {SMerge Xr Ys Temp}
> >>end
> 
> This conversion is perfectly correct in Oz.  We
> chose this one instead 
> of the non-tail-recursive one (below), because tail
> recursion performs 
> better in most cases (in terms of time and space
> performance).
> 
> local Temp in
>     {SMerge Xr Ys Temp}
>     Z = X|Temp
> end
> 
> > then how can I write the code so that it runs in a
> > non-tail-recursive manner?
> 
> Don't nest expressions inside lists or records, but
> evaluate them 
> explicitly before making the list or record.  For
> instance, the 
> expression X|{SMerge Xr Ys} can be written
> 
>     local Zr={SMerge Xr Ys} in X|Zr end
> 
> raph
> 
>
_________________________________________________________________________________
> mozart-users mailing list                           
>    [email protected]
>
http://www.mozart-oz.org/mailman/listinfo/mozart-users
> 

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to