1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 10:37:58 +03:00
Commit Graph

5 Commits

Author SHA1 Message Date
Ben Dudson
a4ca0426a2 Adding map and throw functions
Also some more useful error messages for the arithmetic
operators, rather than returning nil.
2017-12-08 08:19:57 +00:00
Ben Dudson
6b0641cbab Working on quasiquote. Not yet done
Quoting not yet working properly, so symbols in the input
AST are evaluated when they should not be.

Example failing test:

(quasiquote (1 a 3))

The quasiquote function turns this into

(cons 1 (cons a (quote (3))))

rather than

(cons 1 (cons (quote a) (quote (3))))
2017-11-22 23:29:46 +00:00
Ben Dudson
77872467f6 if and fn* forms working
* Added if and fn* handling in eval

* New Env constructor env_new_bind
  which takes a list of binding symbols and expressions

* Macro print_str_mac to shorten raw string printing

* Functions implemented as a list, storing an address to call,
  outer environment, bindings and body

* apply_fn  handles user-defined functions. Calls env_new_bind,
  evaluates the body of the function, and returns the result

Simple tests seem to work:

    user> (def! f (fn* (a b) (+ a b)))
     #<function>
    user>  (f 1 2)
     3
2017-11-04 23:45:54 +00:00
Ben Dudson
c301f1c4ca Adding read/print of nil, true and false
Previously these were read as symbols, not their own type.
Now the reader recognises these as special and converts them
to the correct internal type.
2017-11-03 07:28:55 +00:00
Ben Dudson
1d99c373a1 Using macros to shorten source code
* Definition of symbols with repetition of the name in .len
  replaced by a macro "static"  in macros.mac

* core_environment now uses a macro to add native functions,
  since this involved a lot of code repetition.
2017-11-03 00:14:01 +00:00