forked from kanaka/mal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make: improve efficiency and encapsulation
Readability * Use implicit parameter transmission ($(_list?) instead of $(call _list?,$1), first/lastword instead of word 1/words, $1 instead of $(1). * Use an undefined $(rem) macro and some automatic stripping (if, foreach) to indent code with less calls to `strip` functions. * Name the Make macro implementing a MAL core function exactly like the function (modulo the encoding above) and simplify core_ns accordingly. * Replace empty results representing `nil` with explicit MAL values. * Implement large conditionals with a computed variable name, as already done in printer.mk. For QUASIQUOTE and EVAL, this reduces a lot the diff between steps. * Represent the reader state as an explicit global variable instead of passing the same name as argument again and again. * Merge read-atom into read-form so that the switch on first character is more visible. Encapsulation * Hide most representations into types.mk. * Implement the type as a suffix in order to avoid a conditional in _obj_type. * Implement _error with throw. * Create distinct types for keywords and macros. * Move most metadata and atom stuff from core.mk to types.mk. * Move parameter association from env to types because it hides more about the representation of functions. Representation * Encode Make special characters in all strings/keywords/symbols, so they can be used directly as spaced words and/or variable names for map keys. (The encoding adding separating characters is kept for read-string and seq). * Change representation of numbers/strings/keywords/symbols, reducing the number of Make variables. Various * Allow keyword argument for keyword core function. * Shorten time-mes,slurp,readline... * Remove obsolete stuff: * `get` and `contains?` for vectors * `count` for hash-maps * `_join` from util.mk. * `type` from core.mk. * Add a function listing env_keys for DEBUG-EVAL. * Fix some includes.
- Loading branch information
1 parent
3f6a40f
commit 36f77e9
Showing
19 changed files
with
1,407 additions
and
1,370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
It is often useful to add $(warning /$0/ /$1/ /$2/ /$3/) at the very | ||
start of each interesting macro. | ||
|
||
Recal that foreach does nothing when the list only contains spaces, | ||
and adds spaces between the results even if some results are empty. | ||
|
||
If debugging the reader: | ||
# export READER_DEBUG=1 | ||
|
||
In order to get the equivalent of DEBUG_EVAL in step2: | ||
# export EVAL_DEBUG=1 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.