Arc Forumnew | comments | leaders | submitlogin
2 points by andreuri2000 6138 days ago | link | parent

Sorry, I meant:

  (mac when (test . body)
    `(oaf ,test (do ,@body))) 
  (mac oaf (test conseq)
     `(if ,test ,conseq))


3 points by greatness 6138 days ago | link

The odd thing about this is that I KNOW it should break, but I can't make it do so.

  arc> (let oaf 1 (when 2 3))
  3
I'm pretty sure it is because it evaluates the macro expansion ahead of time.

  arc> (macex '(when 2 3))
  (if 2 (do 3))
Additionally, does anyone know why if isn't considered an object:

  arc> if
  Error: "reference to undefined identifier: _if"

-----

3 points by randallsquared 6138 days ago | link

The symbol 'if is a special operator, not a macro or function. The special operators in Arc's compiler are quote, quasiquote, if, fn, and set.

Probably it would be convenient to have an object tagged as a special operator for those, but it would be documentation, not functional code.

-----

4 points by pg 6138 days ago | link

Special operator is what they're called in CL. I don't know offhand what they're called in Scheme. But what it amounts to is that if only exists as a clause in the compiler.

-----

2 points by randallsquared 6138 days ago | link

"Special operator is what they're called in CL."

Yeah, I know much less about Scheme than CL, so I used the CL term.

-----

1 point by jimbokun 6135 days ago | link

What are they called in Arc? :)

-----

2 points by pg 6135 days ago | link

Special operator sounds good. Or axiom, if we want to be fancy.

-----

1 point by vsingh 6138 days ago | link

Hmm.

I guess the macros in the form are expanded with reference to the context of the entire form (the global context).

Does this mean we don't have macrolet?

-----

1 point by simonb 6138 days ago | link

It probably has more to do with if being one of the primitives (or axioms if you will).

-----