Lisp Interpreter in AS3
So back when Adobe released the Flash 9 Pre-Alpha I took the opportunity to learn AS3 by indulging in one of my favorite pastimes, writing a Lisp interpreter. And what’s even more odd than coding a Lisp interpreter for enjoyment is that when I had it to a point where it was somewhat working, I came up with an actual use for it. Anyway, going into the actual use I found for it is another story that has to do with the interesting bonus you get when you can run the same code on the server as you can on the client. So here’s the link and here’s the list of stuff that seems to work. Update: I posted the source for this, check out the entry here.
- mapcar
- apply,funcall
- every
- reduce
- find-if
- remove-if,remove-if-not
- prog1,prog2,progn
- push
- pop
- incf
- decf
- while
- until
- when
- unless
- with-output-to-string
- multiple-value-list
- multiple-value-call
- multiple-value-prog1
- multiple-value-bind
- nth-value
- dotimes
- dolist
- cons
- rplaca,rplacd
- list
- member
- reverse
- append
- list-length
- car,cdr
- last
- nth,nthcdr
- first,second……tenth
- caar….cddddr
- +,-,*,/
- expt
- mod
- rem
- random
- 1+,1-
- floor
- ceiling
- truncate
- round
- princ
- format
- null
- zerop
- plusp,minusp
- oddp,evenp
- listp,atom
- symbolp
- numberp
- keywordp
- stringp
- quote
- backquote,unquote,unlist
- setq,set
- setf(car,cdr,symbol-value)
- defvar,defparameter
- if,cond
- and,or
- eval
- defun,defmacro
- lambda
- let,let*
- do,do*
- destructuring-bind
- macroexpand
- macroexpand-1
- intern
- symbol-name
- symbol-value
- symbol-function
- macro-function
- gensym
- values
- values-list
- =,/=,eq,equal
- <,<=
- >,>=
- not
Comments
Wow, it’s great!
Would you make the code available?
Can we see the code?
Very nice. Are you going to release the code? I’m learning AS3 (coming from a more functional background) and I’d love to see it.
Glad to see you posted this online. Great job.
I’ll look forward to reading more from you.
I’ll post the code soon, please keep in mind that I was still learning at the time.
n
Man, this is just wicked cool, keep up the good work!
Well done. No need to apologize about code quality; it’s quite an accomplishment.
I’d say your new blog is off to a great start
[…] drawk Well, one thing is for sure AS3 is inspiring programmers and Solve et Coagula made a Lisp interpreter for Flash9/AS3. Silverlight has some programming advantages over flash due to the fact that many languages can be […]
You are my hero.
This is wicked cool. Hey, I’d like to try this using flex_sdk_2/bin/mxmlc. Question, Console extends fl.core.UIComponent which is not part of Flex. Does it have to be UIComponent or Sprite will do? (It’s hard to read Lisp.fla file
@Gustav: I’ve have had it working in Flex before with no issues, although I was building it with FlexBuilder. I did notice that in the code Console extends mx.core.UIComponent not fl.core.UIComponent.
FlexBuilder must perform some extra magic I don’t know about. Tried to extend mx.core.UIComponent with implementing createChildren(), commitProperties(), measure(), and updateDisplayList(), etc. It compiles but not functional. Obviously, I don’t have the complete know-how.
Ended up using 2 mx.controls.TextArea, one for input and another for output. REPL does the evaluation fine. (I think this is how Jatha does its GUI.)
Back to reading Flex API…to implement your elegant Terminal emulation part. Thanks again for the code. Enjoying it very much.
[…] O projeto Colabora pretende incorporar um interpretador de autolisp em sua interface para desenhos. Existe um interpretador Lisp em Actionscript3 que pode ser usado na interface Flash: http://www.solve-et-coagula.com/?p=8 […]
Post a comment