kanaka / mal

mal - Make a Lisp
Other
10.09k stars 2.56k forks source link

VHDL: defmacro! doesn't modify existing functions #604

Open peepo opened 2 years ago

peepo commented 2 years ago

I am just beginning to review the VHDL version, please could this expression be elaborated? ie is this a defect of the implementation? or what is the reason for its inclusion? It has been applied to three of the tests, does it perhaps mean different things? etc. thanks!

dubek commented 2 years ago

I think you're referring to the change in PR #532: before this fix, the two final (optional) tests of in tests/stepA_mal.mal failed:

;;
;; Test that defining a macro does not mutate an existing function.
(def! f (fn* [x] (number? x)))
(defmacro! m f)
(f (+ 1 1))
;=>true
(m (+ 1 1))
;=>false

That PR fixed this by creating a copy of the function given to defmacro!, and only modifying that copy to be a macro.