[plt-scheme] Does the procedure know who called it and how many times?
Majorinc, Kazimir wrote:
> I need "..." parts
>
> (define (f x)
> (let ((p ... ))
> (display "I'm called by ") (display p))
> (if (eq? p f)
> (let ((n ...))
> (display "I called myself recursively ")
> (display n)
> (display " times."))))
>
> (do something)))
>
> Is there any way I can do it without defining new argument of f or new
> global variable?
>
> Thank you.
>
>
Why do you need that? "Continuation Marks" is the closest thing I can
think of. But if a function `foo' calls your `f' in tail position, the
continuation mark of `foo' won't be available. Besides, the function
calls you can install whatever mark they want.
Chongkai