Arc Forumnew | comments | leaders | submitlogin
2 points by almkglor 5890 days ago | link | parent

Well, I did propose a hackish extension, 'symeval, some time back. I should probably push the extension onto Anarki. T.T

  (= pusher cons)
  ; push is defined in arc.arc
  (mac my-push (e l)
    `(symeval!pusher ,e ,l))
  (let pusher (fn (x ls) (+ ls (list x)))
    (prn (my-push 'a '(b c d)))
    (prn (pusher 'd '(a b c))))
Basically symeval is a non-overrideable special form (on the same level as 'set, 'if, etc.)

http://snapvm.blogspot.com/2008/07/symeval.html



1 point by xrchz 5890 days ago | link

I think 'symeval is a possible solution to this problem, and I'm glad somebody thought of it before me. But the question is why you wouldn't use 'symeval on every free variable in your macro template, just in case some newbie decides to let bind one of your "global but internal" names. If you did use 'symeval everywhere (or automatically) you would have something closer (but still a poor approximation) to scheme's hygienic macro system. I think the automatic solution to be found there is more interesting.

-----

2 points by rincewind 5889 days ago | link

I tried that. It doesn't work without knowing which variables are local and arc currently has no way of finding out, what the binding forms are, because all macros are unhygienic.

example:

  (let list '(foo bar) (do (prn list)))
    |    |   unbound    |    |    |
   mac   |             mac   | function 
      function            function

  =>(let (global list) '(foo bar) (do ((global prn) (global list))))
We know that let binds its first argument and aif binds self, but since macros are turing-complete, this cannot be automatically inferred.

-----

1 point by almkglor 5888 days ago | link

expand any macros in sub-expressions, then look at them. That's the advantage of avoiding "first-class macros", whatever their imagined advantages might be. ^^

-----

1 point by xrchz 5890 days ago | link

is it really true that 'set and 'if (and 'symeval...) are completely non-overrideable in arc? is that a convention or something enforced?

-----

1 point by almkglor 5888 days ago | link

It's enforced. For example, you can assign a macro to 'if, but it'll never be used: 'eval will always interpret 'if in its sense, and will never look at your macro.

-----