Clone this wiki locally
There used to be an embedded REPL here, but apparently github doesn’t allow embedding scripts or swfs in wiki pages anymore.
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.
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 has “proper” arbitrary precision integers and ratios, Las3r uses the native (floating-point) AS3 numbers.
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.