Arc Forumnew | comments | leaders | submitlogin
I think its called introspection...
1 point by nitam 6422 days ago | 2 comments
(define (foo x) (* x 2))

>(intro foo)

(define (foo x) (* x 2))

Is there an "intro" function in mzscheme and/or arc?



2 points by absz 6422 days ago | link

One does not exist, but you could always add a new macro in Arc, defi (for "define introspective"), as so (lightly tested):

  (= intro* (table))
  
  (mac defi (name args . body)
    (let defn `(def ,name ,args ,@body)
    `(do1
       ,defn
       (= (intro* ,name) ',defn))))
Then you can do

  arc> (defi foo (x) (* x 2))
  #<procedure: foo>
  arc> (foo 2)
  4
  arc> (intro* foo)
  (def foo (x) (* x 2))
Note that if you use another defi to redefine your function, it will overwrite (intro* foo), but if you use def, it will not be overwritten.

-----

1 point by almkglor 6422 days ago | link

None yet in Arc, not sure about mzscheme.

-----