X-lisp is a simple lisp interpreter. One of the goal of this lisp is to improve the readability of common lisp. It tries to reduce the number of parenthesis and be consistent with the syntax of the language. So far, everything is a function. This is general construct of the language (name args args)
, the first argument inside parenthesis is the function name, and the subsequent is the function arguments.
Make sure you have Deno installed, if not you can install it here.
$ deno install --allow-read github.com/issadarkthing/x-lisp/xlisp.ts
Two major data type in x-lisp is Fn
and Kind
. Fn
is function type which takes at least one argument; the symbol. Everything with the parenthesis is a Fn
type. In fact, the whole module is a big prog
function (we will talk about this later). Every Fn
creates a new scope, the variables defined inside Fn
is only visible within Fn
.
Primitive data types are Kind
s. They are not callable and cannot be the first item inside a parenthesis
.
list
Cons is a list and the only data structure so far in the language. The cons function is a variadic function which means it takes multiple arguments and returns a cons.
function | description |
---|---|
(+ a b) |
add numbers |
(- a b) |
subtract numbers |
(* a b) |
multiply numbers |
(/ a b) |
divide numbers |
function | description |
---|---|
(and a b) |
and && |
(or a b) |
or ` |
(eq a b) |
equal == |
(ne a b) |
not equal != |
(gt a b) |
greater then > |
(ge a b) |
greater then or equal >= |
(lt a b) |
lesser then < |
(le a b) |
lesser then or equal <= |
defun
is a function that takes 3 arguments: identifier, cons, function.
(defun adder (# a b c)
(+ a b c))
set
bind a Kind
to a symbol. The symbol is visible inside the parent scope.
(set a 10 b 12)
if
is not a statement but rather a function which takes 3 Fn
types. The first argument must be an Fn
that returns a bool Kind
.
(if (< 10 11)
(id "so truee")
(id "so wrong"))
Notice the id
function, it is needed there because it needs to turn Kind
type to Fn
type.
Author: issadarkthing
Source Code: https://github.com/issadarkthing/x-lisp
#deno #nodejs #node #javascript