Emlisp is my experiment with language implementation, features and such things.
- install erlang
make ; make run
Few examples of what is already implemented
- datatypes: integer, string, symbol
emlisp> 1 1 emlisp> "test" "test" emlisp> 'a a
- interface to erlang is
(Mod:Fun arg1 arg2 ...)
emlisp> (erlang:+ 2 2) 4 emlisp> (lists:seq 1 5) (1 2 3 4 5) emlisp> erlang:integer_to_list/1 erlang:integer_to_list/1 emlisp> (lists:map erlang:integer_to_list/1 '(1 2 3)) ((49) (50) (51))
- core forms:
car, cdr, cons, eq, and, or, cond, atom, set, error, quote, list, exit, funcall
emlisp> (car '(1 2)) 1 emlisp> (cdr '(1 2)) (2) emlisp> (cons 1 2) (1 . 2) emlisp> (eq 1 1) t emlisp> (and 5 nil) nil emlisp> (or 5 nil) 5 emlisp> (cond ((eq 5 1) 'one) ((eq 5 2) 'two) (t 'other)) other emlisp> (atom '(1 2)) nil emlisp> (set 'x 5) 5 emlisp> (erlang:+ x x) 10 emlisp> (error 'some_error x) error some_error: (5) emlisp> a error env_not_found: a emlisp> (quote a) a emlisp> (list 1 2) (1 2) emlisp> (set 'f (list (lambda (x) (car x)))) (#<{lambda,[{symbol,<<"x">>}],[[{symbol,<<"car">>},{symbol,<<"x">>}]],global}>) emlisp> (funcall (car f) '(a b c)) a emlisp> (exit) ** exception throw: emlisp_exit
- lists, quotes
emlisp> '(1 2 (erlang:+ 1 2)) (1 2 (erlang:+ 1 2))
- lambdas
emlisp> (lambda (x) x) #<{lambda,[{symbol,<<"x">>}], [{symbol,<<"x">>}], [{dict,0,16,16,8,80,48, {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}, {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}}]}> emlisp> ((lambda (x) x) 4) 4 emlisp> (set 'f ((lambda (x) (lambda () x)) 7)) #<{lambda,[], [{symbol,<<"x">>}], [{dict,1,16,16,8,80,48, {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}, {{[], [[{symbol,<<"x">>}|7]], [],[],[],[],[],[],[],[],[],[],[],[],[],[]}}}]}> emlisp> (f) 7
- global environment is saved and shared between repls in em_env process
- mutable enclosing environments:
emlisp> (set 'm (let ((x 5)) (cons (lambda () x) (lambda (y) (set 'x y))))) (#<{lambda,[],[{symbol,<<"x">>}],1439404445176175}> . #<{lambda,[{symbol,<<"y">>}], [[{symbol,<<"set">>}, [{symbol,<<"quote">>},{symbol,<<"x">>}], {symbol,<<"y">>}]], 1439404445176175}>) emlisp> (funcall (car m)) 5 emlisp> (funcall (cdr m) "five") "five" emlisp> (funcall (car m)) "five"
to both definition and call environments
- Macros
- let
- progn
- self-hosted test framework
- tests
- generalized booleans
- control that number of , corresponds to number of ` (on grammar level?)
- object system
- erlang code generation
- DONE node-wide shared state?
- mutable environments?
- type system