| Sometimes tracking down errors can be a pain. Here's a snippet that helps to trace some errors by rebinding 'def to a wrapper macro that generates error-tracking code:  Function call on inappropriate object nil
 In arc3.1, this gives  (unless (bound 'unsafe-def)
    (assign unsafe-def def)
    (mac def (name args . body)
      `(unsafe-def ,name ,args
         (on-err (fn (ex) (err:string "error in "
                                      ',name 
                                      (tostring:pr:list ,@(flat args)) 
                                      "\n"
                                      (details   ex)))
                 (fn ()   ,@body)))))
 I don't know how to make the top-level error handler "disp" instead of "write" the error message, but you see the idea.  arc> (def mymap (f xs) (map f xs))
  #<procedure: mymap>
  arc> (def foo (bar) (mymap bar (list 1 2 3)))
  #<procedure: foo>
  arc> (foo nil)
  Error: "error in foo(nil)\nerror in mymap(nil (1 2 3))\nFunction call on inappropriate object nil (1)"
 It's primitive but helpful. The "unless (bound ..." guard is necessary if you reload your code during development; without it 'def becomes an infinite recursion. |