T
Tomasz Wegrzanowski
Hello 
Maybe some of you guys will be interested.
I wrote a small Lisp interpretter embedded in Ruby.
The emdedding is very tight - Lisp macros are Ruby Proc objects
and Lisp lists are Ruby Arrays (so actually cdr/cons copy).
It is somewhat more Scheme-ish (or even Goo-ish) than Common Lisp-ish,
but the macro system is more like Common Lisp's.
[obj method args] is a reader macro for (send obj 'method args),
which expands to obj.send
method, *args).
Here are some examples:
; Fib function
(defun fib (n)
(if (<= n 1)
1
(+ (fib (- n 1)) (fib (- n 2)))
)
)
(print (map fib '(1 2 3 4 5)))
; A small HTTP server
(ruby-eval "require 'webrick'") ; import module
(let HTTPServer (ruby-eval "WEBrick::HTTPServer")) ; bind class name
; Configure the server
(let config [Hash new])
[config set 'Port 1337]
; Tell the class to make us a server object
(let server (send HTTPServer 'new config))
; Tell server to call our Hello World handler
(send server 'mount_proc "/hello"
(lambda (req res)
[res body= "<html><body><h3>Hello, world!</h3></body></html>"]
[res field_set "Content-Type" "text/html"]
)
)
; Tell the server to go !
(send server 'start)
Because it supports macros you can do things like:
(def-server-html-mount server "/hello"
(html (body (h3 "Macros greet you")))
)
and that's pretty cool, because Ruby itself doesn't support macros
and now you can use macros almost in Ruby
The download: http://zabor.org/taw/rlisp/
Documentation is only on my blog for now:
* http://t-a-w.blogspot.com/2006/07/rlisp-lisp-naturally-embedded-in-ruby.html
* http://t-a-w.blogspot.com/2006/07/rlisp-gets-basic-oo-support.html
* http://t-a-w.blogspot.com/2006/07/rlisp-gets-http-support.html
It uses Martin Traverso's Ruby port of ANTLR 3 for parsing.
Well, that's pretty much all
If you have any questions about it, just ask
(on the mailing list, by private mail, or on the blog)
Maybe some of you guys will be interested.
I wrote a small Lisp interpretter embedded in Ruby.
The emdedding is very tight - Lisp macros are Ruby Proc objects
and Lisp lists are Ruby Arrays (so actually cdr/cons copy).
It is somewhat more Scheme-ish (or even Goo-ish) than Common Lisp-ish,
but the macro system is more like Common Lisp's.
[obj method args] is a reader macro for (send obj 'method args),
which expands to obj.send
Here are some examples:
; Fib function
(defun fib (n)
(if (<= n 1)
1
(+ (fib (- n 1)) (fib (- n 2)))
)
)
(print (map fib '(1 2 3 4 5)))
; A small HTTP server
(ruby-eval "require 'webrick'") ; import module
(let HTTPServer (ruby-eval "WEBrick::HTTPServer")) ; bind class name
; Configure the server
(let config [Hash new])
[config set 'Port 1337]
; Tell the class to make us a server object
(let server (send HTTPServer 'new config))
; Tell server to call our Hello World handler
(send server 'mount_proc "/hello"
(lambda (req res)
[res body= "<html><body><h3>Hello, world!</h3></body></html>"]
[res field_set "Content-Type" "text/html"]
)
)
; Tell the server to go !
(send server 'start)
Because it supports macros you can do things like:
(def-server-html-mount server "/hello"
(html (body (h3 "Macros greet you")))
)
and that's pretty cool, because Ruby itself doesn't support macros
and now you can use macros almost in Ruby
The download: http://zabor.org/taw/rlisp/
Documentation is only on my blog for now:
* http://t-a-w.blogspot.com/2006/07/rlisp-lisp-naturally-embedded-in-ruby.html
* http://t-a-w.blogspot.com/2006/07/rlisp-gets-basic-oo-support.html
* http://t-a-w.blogspot.com/2006/07/rlisp-gets-http-support.html
It uses Martin Traverso's Ruby port of ANTLR 3 for parsing.
Well, that's pretty much all
(on the mailing list, by private mail, or on the blog)