public
Description: A lisp compiler for the AVM2.
Home | Edit | New

Home



What functions are available? The repl is currenly loading all code from las3r.core.lsr. Documented here.

Hey! This looks like Clojure! Las3r is based on the Clojure source code, so they have a lot in common. For instance, the reader is almost a line-by-line port of the Clojure reader. So if you know the syntax of Clojure, you know the syntax of las3r.

However, las3r should not be considered a port of Clojure.

Why not? There are some important differences. For example:
  • Clojure has lots of support for concurrent programming. Las3r has none. There’s no such thing as concurrency in Flash, so this was a no-brainer.
  • Clojure lets you call anything that implements IFn. In las3r, you may only invoke native AS3 Functions (all functions defined in las3r are also AS3 Functions).


What’s something fun to try?

(def pet (let [p (new flash.display.Sprite) g (. p graphics)]
  (doto g
    (beginFill 0xFF0000)
    (drawRect 0 0 50 50)
    (endFill))
   (. *stage* (addChild p)) p))
(. *stage* (addEventListener "enterFrame" (fn [e] (set! (. pet x) (+ (. pet x) 2)))))

Compiler or interpreter? Each lisp form is compiled directly to AVM2 bytecode and then loaded into the hosting swf’s application domain. This is analogous to how how Clojure compiles and dynamically loads Java compilation units.

Can you compile lisp “ahead-of-time” to a swf? Yes! For example, the repl you see above is loading a swf that contains all the bytecode for las3r.core.

What’s it good for? las3r is easy to embed. For example, you can drop the included las3r repl into any flash or flex application. This makes it a useful tool for runtime inspection and tweaking. Eventually, las3r should be a good language for writing Flash apps and games.

Is there an emacs mode? Yes. las3r-mode.el is included in the source tree. Also included: basic support for sending lisp forms from emacs to Flash for evaluation.

Last edited by aemoncannon, Wed Mar 25 22:39:03 -0700 2009
Home | Edit | New
Versions: