guile-devel
[Top][All Lists]
Advanced

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

Re: Eval, tail calls, (current-module), and backward compatibility


From: Andy Wingo
Subject: Re: Eval, tail calls, (current-module), and backward compatibility
Date: Wed, 18 Jan 2012 23:27:21 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

On Wed 18 Jan 2012 23:21, address@hidden (Ludovic Courtès) writes:

> Andy Wingo <address@hidden> skribis:
>
>> On Wed 18 Jan 2012 22:18, address@hidden (Ludovic Courtès) writes:
>>
>>>         (('apply (f args))
>>>          (apply (eval f env) (eval args env)))
>>
>> This is in primitive-eval (and here, `eval' is locally bound).  Mark is
>> talking about R5RS `eval' (`scm_eval').
>
> OK, but ‘scm_eval’ is not recursive, so no wonder it’s not
> tail-recursive.  :-)
>
> (I’m confident I’m missing something, but I just fail to see what.  ;-))

Hee hee :)  The point is that this should loop indefinitely:

  (define (loop)
    (eval '(loop) (current-module)))
  (loop)

It doesn't, because the function that "eval" resolves to is implemented
in C.  If we implemented it in Scheme, it still wouldn't work, because
it would be like:

  (define (loop)
    (with-fluids ((%%%current-module (current-module)))
      (primitive-eval '(loop))))
  (loop)

and the with-fluids makes it not tail recursive.

Andy
-- 
http://wingolog.org/



reply via email to

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