Arc Forumnew | comments | leaders | submitlogin
Help with a macro
6 points by wfarr 6095 days ago | 4 comments
I asked about this in IRC, but nobody quite seemed to know.

I'm working on something in Arc right now, and having noticed that html.arc lacks support for <div> I set about implementing it myself.

Here's my current code:

  (attribute div align   opsym)
  (attribute div class   opstring)
  (attribute div dir     opsym)
  (attribute div id      opsym)
  (attribute div lang    opstring)
  (attribute div onclick opstring)
  (attribute div style   opstring)
  (attribute div title   opstring)

  (mac div (args . body)
    `(tag (div ,args) ,@body))
Is anyone willing to give me a hand in figuring this out? =)


11 points by cadaver 6095 days ago | link

Since the first parameter to 'div is going to be a list of paramters/values you have to unquotesplice it:

  (mac div (args . body)
    `(tag (div ,@args) ,@body))
               ^^

  arc>(attribute div align opsym)
  #<procedure: opstring>
  arc>(mac div (args . body) `(tag (div ,@args) ,@body))
  #3(tagged mac #<procedure>)
  arc> (div (align 'left) (tag (hr)))
  <div align=left><hr></hr></div>"</"

-----

1 point by wfarr 6095 days ago | link

Thanks a lot for the help.

Is there any particular reason why there's a random trailing "</" ?

-----

8 points by cadaver 6095 days ago | link

The <div ... </div> is written to stdout; it's a side-effect, not the result of the expression. It is the trailing "</" that's the result of the expression, and therefore gets written to stdout after the expression's side-effects.

I don't think 'tag means to return "</" in particular. It's just that 'pr -- which is used to write the closing tag like so: (pr "</" ...) -- returns its first argument and 'tag returns the value that's returnd by 'pr.

-----

1 point by wfarr 6094 days ago | link

Thanks again!

-----