BLisp is a lisp like interpreted language designed in Java. The program includes an IDE and was designed to be similar to SCAR. Currently, I have stopped development on this but may resume it at any time.
BLisp was created to function as a fast, efficient, scripting language totally written in Java. It includes a hand written parser/lexer combo which reads the easy-to-parse lisp syntax. Then the code is evaluated as a single expression. This form of evaluation unique to lisp means that every expression evaluated returns a value, and the whole program is made up of a hierarchy of evaluations. This makes for very efficient code and source.
All of the executable information is stored in the source, there is no intermediate. An instance of a class implementing the Visitor interface, such as the included Interpreter class, is able to take parsed source code and execute it via callbacks to retrieve and execute procedures and core methods, provided by the CoreMethods class.
The language of BLisp is essentially lisp without the low level functions. It was created as a type of scripting language intended to cover logic, math, data, and other things. It contains a plugin structure that allows one to extend the language with functions written in java code. Because it is based on lisp, it is strongly typed, but works as a dynamically typed language. It is especially useful in coding algorithms. Since data is the same as code, a BLisp program can dynamically modify itself and create new procedures and code at runtime.
There are two main types of structures in the code, macros and functions. The only real difference between them is that macros do not evaluate their arguments, but functions do. This being said, all of BLisp code is made up of lists, contained in parentheses delimited by white space, that begin to a call to a method, defined as either a function or a macro. The macros defun and defmacro create functions and macros in the Visitor that invokes them, and the names are from that point on valid as the function names in lists.
Most Lisp code will work in BLisp with very few modifications. That being said, you would want to check it before hand to make sure it works as expected. These are a few algorithms that wrote to test the language with.
(defun quick-sort (data comp)
(if (> (size data) 1) (let ((pivot (remove data (div (size data) 2)))) (let ((left (make-list 0)) (right (make-list 0))) (dolist (value data) (if (funcall comp value pivot) (push left value) (push right value))) (concat (quick-sort left comp) (list pivot) (quick-sort right comp)))) (quote data)))
(quick-sort (list 1 5 35 4 7 95 48 55 1 7) (lambda (a b) (< a b)))
Newton's Method and Square Roots
(defun derrive (funct &optional (h 0.000001))
(lambda (x) (div (- (funcall funct (+ x h)) (funcall funct x)) h)))
(defun solve (funct &optional (guess 0.0) (error 0.000001)) (let ((deriv (derrive funct)) (last 1000)) (until (< (abs (- last guess)) error) (setf last guess) (setf guess (- guess (div (funcall funct guess) (funcall deriv guess)))))) (quote guess))
(defun sqrt (x) (solve (lambda (y) (- (mul y y) x))))
(defun recint (func &optional (error 0.000001) (low 0) (high 1) (last 0))
(let((mid (div (+ low high) 2)) (a (funcall func low)) (b (funcall func mid)) (c (funcall func high)) (left (mul (- mid low) (div (+ a b) 2))) (right (mul (- high mid) (div (+ b c) 2)))) ;(format t "%0" (abs (- 0 last))) (if (< (abs (+ left right (- 0 last))) error) (+ left right) (+ (recint func (div error 2.0) low mid left) (recint func (div error 2.0) mid high right)))))
(recint (lambda (x) (div 4 (+ 1 (mul x x)))))