Hello
Here's a simple patch to make it possible to get the results of previous evaluations in the repl. (Or have I overlooked an existing mechanism for that (other than through the serial number)?) It creates |it| and similar global variables in the default namespace.
What (I think) I would prefer, but don't know how to do, is:
- make those be bound lexically to the code being entered instead, so that they don't pollute any namespace and don't need any namespace vodoo to be accessed from the entered code. I imagine that the variables could be put into the lexical environment of the code being eval'ed, but simply wrapping with `(let ((it ,old-it)) ,body) wouldn't do (this would at least break top-level defines).
- make those variables/bindings per-thread, or maybe even per-repl. (I'd prefer not having to type parens around parameter objects. But shoveling around the values between lexical context and internal state or parameter object values would solve this.)
Thanks Christian.
--- gambc40b17/lib/_repl.scm.1_orig 2006-01-08 19:19:02.000000000 +0100 +++ gambc40b17/lib/_repl.scm 2006-03-03 03:35:09.000000000 +0100 @@ -1771,6 +1771,12 @@
(##exit))
+(##namespace ("" it it1 it2 it3)) +(define it #!void) +(define it1 #!void) +(define it2 #!void) +(define it3 #!void) + (define-prim (##repl-within cont write-reason)
(define (with-clean-exception-handling repl-context thunk) @@ -1943,6 +1949,10 @@ (macro-repl-context-cont repl-context) repl-context (lambda (results) + (set! it3 it2) + (set! it2 it1) + (set! it1 it) + (set! it results) (##call-with-values (lambda () results)
Afficher les réponses par date
This patch has the ugly side effect that gambit's search algorithm for functions is "broken", it now always returns 'it (or 'it1 etc.) as the name of a function:
error
#<procedure #2 it>
error
#<procedure #2 it1>
So a solution which binds 'it lexically would be better also because of this issue.
Christian.