guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: extending FEM enginering package with Guile


From: Paul Jarc
Subject: Re: extending FEM enginering package with Guile
Date: Thu, 08 Jan 2004 01:04:39 -0500
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux)

Keith Wright <address@hidden> wrote:
> Don't use while in the first place.  Use "named LET".  Then BREAK
> is just computing the final answer, and "continue" is calling
> the named LET procedure.

Only if the final answer (or call to the named let) appears in tail
position.

> (let loop ([var1 init1]
>            [var2 init2])
>   (if (cond1) (compute answer))
>   ; ...
>   (if (cond2) (loop (new-var1) (new-var2)))
>   ; ...
>   (loop (new-var1) (new-var2))  ; end-of-loop = continue
> )

This is an infinite loop.  Maybe you meant:

(let loop ((var1 init1)
           (var2 init2))
  (cond
   ((cond1) (compute answer))
   ((cond2) (loop (new-var1) (new-var2)))
   (else    (loop (new-var1) (new-var2)))))

I'm not sure what you mean by your "end-of-loop = continue" comment.
If you mean that falling through to the end of the let body will
result in another loop iteration, then that's wrong.  If you mean that
an explicit call to loop will result in another loop iteration, then
that's right.  But if anything appears after it - i.e., if it's not in
tail position - then the result of the inner call won't be passed back
as the result of the outer computation.


paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]