On Jun 3, 2009, at 4:33 PM, Ramana Kumar wrote:

So, the debugger uses call/cf (short for call-with-continuation- frame)
which is like the "raw" equivalent of call/cc.  The debugger doesn't
need to do anything with the actual frame other than comparing it with
the last captured frame: if they're eq?, we're in tail call, if not,
then it's a nontail call.  The debugger then treats the two cases
accordingly (details omitted).

Incidentally a footnote in "A Monadic Framework for Delimited
Continuations" says "In Chez Scheme, this is accomplished by comparing
the current continuation against a base continuation using eqv*...
*Unfortunately, this makes the code unportable; to our knowledge, no
other Scheme system allows eqv? to be used on continuations in this
manner." I suppose with actual stack frames eq? is going to work. But
do you any Scheme systems apart from Chez (and I think Ikarus too)
that support eqv? on continuations? Is it essentially the same as
supporting eqv? on procedures?

Basically, more or less.

So, in Chez, two continuations (procedures) are eq? if they return
to the same context.  So,

(call/cc
  (lambda (k0)
    (call/cc
      (lambda (k1)
        (eq? k0 k1)))))
=>
#t

in Chez.  While Ikarus doesn't do that, it has something equivalent:

(call/cf
  (lambda (f0)
    (call/cf
      (lambda (f1)
        (eq? f0 f1)))))
=>
#t

There are caveats here when you use tracing or debugging is that
sometimes the guarantee is lost (making it a nonguarantee really
and that's why this not a documented feature of Ikarus and I
presume in Chez for the same reason).

E.g., in Chez:

(call/cc
  (lambda (k0)
    (let noloop ()
      (call/cc
        (lambda (k1)
          (eq? k0 k1))))))
=>
#t

(call/cc
  (lambda (k0)
    (trace-let noloop ()
      (call/cc
        (lambda (k1)
          (eq? k0 k1))))))
=>
|(noloop)
|#f
#f

ditto for Ikarus.  Tracing and debugging "steal" one frame
at a tail call iff that call is not a tail of a previously
traced/debugged call.  This does not, btw, affect the space
complexity of tail calls in any observable way.  The only
catch is that thieves have to cooperate and share the frame
they steal, or else it will be obvious:
  https://bugs.launchpad.net/ikarus/+bug/377878

Aziz,,,

Reply via email to