Arc Forumnew | comments | leaders | submitlogin
2 points by absz 6422 days ago | link | parent

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.