Arc Forumnew | comments | leaders | submitlogin
2 points by evanrmurphy 5124 days ago | link | parent

Your 'whatever function rebinds 'test only for the lexical scope of the function definition. After defining the macro and then the function as you have, 'test is still bound to the macro:

  arc> (mac test (name actual compare-fn expected)
         "test macro")
  #(tagged mac #<procedure: test>)
  arc> (def whatever (test xs)
         test)
  #<procedure: whatever>
  arc> test
  #(tagged mac #<procedure: test>)
  arc> (test nil nil nil nil)
  "test macro"
The binding of function parameters behaves like 'let in this regard, affecting a variable's value within the lexical scope of the block but producing no side effects on it outside.


2 points by evanrmurphy 5124 days ago | link

We can even pass 'test as a parameter to 'whatever and it will retain its original value as a macro, because the rebinding of 'test as a parameter was only for the function's definition, not for a call to that function:

  arc> (whatever test nil)
  #(tagged mac #<procedure: test>)

-----

2 points by evanrmurphy 5124 days ago | link

I think this response misunderstands exactly the trouble you were talking about. Sorry if I confused matters.

-----