Skip to content

plexus/ruby_lisp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RubyLisp

A LISP in pure Ruby

  • Lisp-1
  • Dynamically scoped (closures)
  • Macros
  • Interop
  • REPL
  • Use lambdas as Ruby blocks
  • Variable argument functions

Run bin/ruby_lisp to get a REPL, or pass it a filename to execute the file

Example:

(rb-require "net/http")

(defun uri (u)
  (rb-send-const 'Kernel 'URI u))

(defun http-get (u)
  (rb-send-const 'Net::HTTP 'get_response (uri u)))

(let ((response (http-get "http://devblog.arnebrasseur.net")))
  (println (rb-send response 'body)))

There are two interop primitives, rb-const and rb-send, for example println is implemented as

(defun println (expr)
  (rb-send (rb-const 'Kernel) 'puts expr))

Have a look at bootstrap.rl for convenience functions built on top of these two, like require, rb-new and rb-send-const.

This is a minimal implementation, mostly intended for education. It complements my talk Growing a LISP.

Missing features

Lots, obviously, but the ones that would be most useful to have:

  • comments
  • backquotes

License

GNU General Public License v3

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages