Arc Forumnew | comments | leaders | submitlogin
2 points by ylando 5250 days ago | link | parent

Suppose that you want to write a macro that define a function:

  (mac def-func (func-name func-body)
    (w/uniq first-arg
      (w/uniq rest-arg
         `(def ,func-name (,first-arg . ,rest-arg)
             ,@func-body))))
And it will not work. There is a problem with using dot in quasiquote.


3 points by shader 5250 days ago | link

So your real question is why dots don't work in quasiquote, and what should be done to fix them. That's a question that we can relate to a lot better than what we originally thought was "I don't like dots"

-----

2 points by evanrmurphy 5250 days ago | link

Would someone mind being more explicit about how it doesn't work? After dotting the outer definition's rest parameter as well so that the first line reads,

  (mac def-func (func-name . func-body)
it seems to be working for me:

  arc> (def-func 1+1 (+ 1 1))
  #<procedure: 1+1>
  arc> (1+1 nil)
  2
If you're interested, here's a version of your macro with a few things cleaned up (some changes only subjectively better):

  (mac def-func (name . body)
    (w/uniq (first rest)
      `(def ,name (,first . ,rest)
         ,@body)))

-----

1 point by ylando 5250 days ago | link

It don't work with jarc16, it don't work with arc3. What is your version of arc?

-----

1 point by evanrmurphy 5250 days ago | link

arc3.1. So did you get an error message on trying

  (def-func 1+1 (+ 1 1))
or what? Did you dot the func-body rest parameter as well?

-----

1 point by ylando 5250 days ago | link

It works on arc3.1.

-----