Tuesday, August 16, 2011

JavaScript DSL

I have created a DSL that directly translates to JavaScript.

(function factorial [n]
    (ternary-operator (== n 0)
      (* n (factorial (- n 1))))))

The above code directly translates into the JavaScript factorial function. Along with prxml, this allows me to create entire web pages entirely in Lisp:

    [:title "Welcome"]]
    [:script {:type "text/javascript"}
      [:raw! (to-js '(alert "Hello World"))]]]]

I look forward to being able to use this to develop lots of webpages.

No comments:

Post a Comment