;;; in Arc + is defined
;;; macro writers code depends on Arc's + ;;; but doesn't insure it always uses Arc's +
(mac foo () (list '+ 1 2))
;;; app writers code
(* 2 (foo)) ;;; 6
;;; app writer doesn't know foo depends on Arc's + ;;; and decides to redefine +
(= + (fn ((o x) (o y)) (prn "gotcha")))
(* 2 (foo)) ;;; error
;;;;;;;;;;;;;;;;;; the following works ;;;;;;;;;;;;;;;;;;;;
;;; macro writers code is tricky and ugly ;;; but will always use Arc's +
(= g (uniq))
(eval (list '= g '+))
(eval (list 'mac 'foo `() `(list (quote ,g) 1 2)))
;;; redefining + doesn't affect the addtion function ;;; used in the foo macro
;;;;;;;;;;;; if foo is a function then it is easy ;;;;;;;;;;
;;; library writers code is easy because ;;; the original + can be in a closure
(= foo ((fn () (let plus + (fn () (plus 1 2))))))
;;; redefining + doesn't affect the addtion function ;;; used in the foo function
-----