Arc Forumnew | comments | leaders | submitlogin
2 points by rocketnia 2926 days ago | link | parent

I bet the error is coming from here:

  `(=
     ...
     (with ,'(name ,name age ,age))
     ...)
There's an unquote inside another unquote there, so it's actually trying to do a function call (unquote name), which doesn't work because `unquote` is undefined. There's also the problem that your (with ...) body is sitting outside the (with ...) form.

A small fix would be to generate this instead:

  `(=
     ...
     (with ,`(name ,name age ,age)
       ...))
Here's a patch for that:

   (mac defobject (class attrs)
     (with (letargs (mappend [list _ (list 'unquote _)] attrs)
            attrfns (map [attrfn _] attrs))
       (w/uniq var
       `(mac ,class (,var ,attrs)
  -       `(= ,,var (with ,',letargs)
  -           (dlambda
  -             ,',@attrfns))))))
  +       `(= ,,var
  +           (with ,(list 'quasiquote ,letargs)
  +             (dlambda
  +               ,',@attrfns)))))))
I haven't read your code very closely or tested whether this change makes it work, so there might be other bugs in there.