Arc Forumnew | comments | leaders | submitlogin
3 points by eds 6129 days ago | link | parent

It almost works... but unfortunately because we don't yet have first class macros it fails with:

  Error: "Bad object in expression #3(tagged mac #<procedure>)"


2 points by absz 6129 days ago | link

Try removing the comma in front of olddef; it should work then.

-----

4 points by Darmani 6129 days ago | link

Unfortunately, that won't work because the form is being returned to a place outside the closure where olddef was defined; when eval is given the form containing olddef, it will not recognize it.

Here's a better definition:

  (let olddef def
    (mac def (name args . body)
      (if (acons name)
        `(def= ,(cadr name) ,args ,@body)
        (apply (rep olddef) (cons name (cons args body))))))

-----

2 points by absz 6128 days ago | link

Shouldn't that be (mac def ...)?

Anyway, nice work, but damn do we need 1st-class macros.

-----

3 points by Darmani 6128 days ago | link

Oops -- thank you. Fixed.

-----