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

How would using ampersand over dot make macro writing much easier? Is it just that you find the notation more intuitive, or is there something else?

Personally I prefer the dot because I think it looks less jarring and there's the connection with improper lists, as pg mentions in the tutorial (http://ycombinator.com/arc/tut.txt):

  (These conventions are not as random as they seem.  The parameter
  list mirrors the form of the arguments, and a list terminated by
  something other than nil is represented as e.g. (a b . c).)


2 points by ylando 5039 days ago | link

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 5039 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 5039 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 5039 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 5039 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 5039 days ago | link

It works on arc3.1.

-----