Arc Forumnew | comments | leaders | submitlogin
that
12 points by waterhouse 5447 days ago | discuss
In Common Lisp, the variable * is bound to the value of the last expression returned by the toplevel process, so that one can, e.g.:

  * (range 1 10)
  (1 2 3 4 5 6 7 8 9 10)
  * (reverse *)
  (10 9 8 7 6 5 4 3 2 1)
  * (mapcar #'square *)
  (100 81 64 49 36 25 16 9 4 1)
I found this feature very useful and was annoyed at Arc's apparent lack of it. Today I decided I'd hack Arc to implement something like this feature. Obviously one couldn't use *, because that would clobber the multiplication function[1], so what else? Some English anaphor; probably not 'it, since I expect to see that in an 'aif or 'awhen or something. I opened up ac.scm, figuring I'd rewrite the toplevel procedure... and lo and behold:

  (define (tl2)
   ...
      (let ((expr (read)))
         ...
            (let ((val (arc-eval expr)))
              (write (ac-denil val))
              (namespace-set-variable-value! '_that val)
              (namespace-set-variable-value! '_thatexpr expr)
              (newline)
              (tl2)))))))
pg already did it! 'thatexpr and 'that are bound, respectively, to the last input expression and the last output value to the toplevel. I swear that I was thinking of using the name 'that, too. (After the fact, I do remember seeing this when looking through ac.scm a long time ago, before I understood it, but any memory of this was nowhere near my conscious mind.) Anyway, using the Arc REPL will now be a little bit more convenient for me.

[1]This is approximately the second time I've wanted CL's function namespace. The first time was when I wanted to use 'list as a parameter in Scheme, and decided on 'liszt; I later learned to use 'xs and haven't looked back. Meanwhile, in CL, I've used funcall and #' more times than I care to estimate. I do not miss that when hacking in Arc.