From c714889a985497442ec2aa600a63a4581c71b3ae Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez Date: Wed, 15 May 2019 06:07:45 +0200 Subject: [PATCH] Move test that macro do not mutate functions as optional in stepA --- process/guide.md | 4 ++++ tests/step8_macros.mal | 8 -------- tests/stepA_mal.mal | 9 +++++++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/process/guide.md b/process/guide.md index 79151762..44ba12cf 100644 --- a/process/guide.md +++ b/process/guide.md @@ -1537,6 +1537,10 @@ diff -urp ../process/step9_try.txt ../process/stepA_mal.txt result of reading the next next form (2nd argument) (`read_form`) and the next form (1st argument) in that order (metadata comes first with the ^ macro and the function second). + * If you implemented as `defmacro!` to mutate an existing function + without copying it, you can now use the function copying mechanism + used for metadata to make functions immutable even in the + defmacro! case... * Add a new "\*host-language\*" (symbol) entry to your REPL environment. The value of this entry should be a mal string diff --git a/tests/step8_macros.mal b/tests/step8_macros.mal index a86b6603..8beea012 100644 --- a/tests/step8_macros.mal +++ b/tests/step8_macros.mal @@ -172,11 +172,3 @@ x ;=>"MAL" (->> [4] (concat [3]) (concat [2]) rest (concat [1])) ;=>(1 3 4) - -;; 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 diff --git a/tests/stepA_mal.mal b/tests/stepA_mal.mal index 84fa281c..2e0549ba 100644 --- a/tests/stepA_mal.mal +++ b/tests/stepA_mal.mal @@ -279,3 +279,12 @@ ;=>55 (> (time-ms) start-time) ;=>true + +;; +;; 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