How to determine the top caller in Slime's REPL
- From: Philippe Lorin <palpalpalpal@xxxxxxxxx>
- Date: Wed, 31 May 2006 18:31:37 +0200
In Slime, I need to be able to determine dynamically whether the "top caller" of the currently executing code is some specifically marked expression, or just one of all the other expressions typed at the REPL which might be running in parallel.
An example should make the idea clearer.
(defun f () ; This function is just here to show that the
(in-marked-expression)) ; test is not necessarily lexically enclosed
; in the marked expression.
(mark-and-eval
(do () (nil) ; Just an infinite loop, to make sure the
; expression will be running forever in parallel.
(assert (f)))) ; Here, IN-MARKED-EXPRESSION must always return T.
(f) ; Note that the preceding (DO ...) is still running.
=> NIL ; Here, IN-MARKED-EXPRESSION must always return NIL.
I can write the marked expression with complete freedom (for instance, I can add wrappers around it or preprocess it), but all the other expressions typed after it at the REPL are not under my control.
Among the ideas I've tested, the following one sounded the most promising, but it doesn't work. I don't understand why.
(defun in-marked-expression ()
(not (null (find-restart 'restart-in-restart-case)))) ; Are we in the
; restart-case?
(defun f ()
(in-marked-expression))
(restart-case
(do () (nil)
(assert (f)))
(restart-in-restart-case () nil))
(f)
=> T ; :(
Can anybody help?
.
- Prev by Date: Re: xml and s-expression
- Next by Date: Re: Just can't hear enough about Cells?
- Previous by thread: Green threads and Web-application
- Index(es):