Arc Forumnew | comments | leaders | submitlogin
1 point by evanrmurphy 5008 days ago | link | parent

The example can be made less verbose with the help of a simple macro to eliminate the (.html ($ 'body) ...) repetition:

  ; don't confuse body the parameter
  ; with 'body the DOM element in
  ; this macro

  (mac draw body
    (.html ($ 'body) @body))

  ($ (fn ()
    (draw
      (+ (<input>) (<button> "submit")))
    (.click ($ 'button) (fn ()
      (= said (.val ($ 'input)))
      (draw (<a> href '#))
      (.click ($ 'a) (fn ()
        (draw
          (+ "you said: " said))))))))
Also note that this is a client-side only solution to the Arc Challenge problem. Since LavaScript itself is written in JavaScript and going to be made available through the NPM, server-side and hybrid solutions will also be possible using a Node web server.