diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-06-28 06:22:24 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-06-28 06:22:24 -0700 |
commit | ac18f54aca98531e8200d8bcc012555c1f195ec1 (patch) | |
tree | c43f2f7517c5c3772afa753c68ef52d566e4e7b3 /stdlib/type.tl | |
parent | 4462afdd0a80cbf8c73faa58fb0540b70bd0d890 (diff) | |
download | txr-ac18f54aca98531e8200d8bcc012555c1f195ec1.tar.gz txr-ac18f54aca98531e8200d8bcc012555c1f195ec1.tar.bz2 txr-ac18f54aca98531e8200d8bcc012555c1f195ec1.zip |
constantp: fully expand; recognize functions.
This patch improves the constantp function dramatically. It
now performs a full expansion of its argument, and recognizes
all of the constant foldable functions that the compiler
recognizes.
* eval.c (const_foldable_s): New symbol variable.
(const_foldable_hash): New static variable.
(constantp_noex): Look up function in the hash table of const
foldable functions, including in the case when it appears in a
dwim form as in [+ 2 2] which is (dwim + 2 2). In this case,
recursively check the arguments for constantp_noex.
We get the hash table of foldable functions from the
sys:%const-foldable% variable, which comes from an autoloaded
module.
(constantp): Fully expand the input form, not just m
macroexpand.
(eval_init): Register the const_foldable_s variable.
* lisplib.c (constfun_instantiate, constfun_set_entries): New
static functions.
(lisplib_init): Register auto-loading of constfun module
via new static functions.
* stdlib/compiler.tl; Load the constfun module if
%const-foldable% is not defined.
(%const-foldable-funs%, %const-foldable%): Removed from here.
* stdlib/constfun.tl: New file.
(%const-foldable-funs%, %const-foldable%): Moved here.
* txr.1: Documented changes to constantp.
Diffstat (limited to 'stdlib/type.tl')
0 files changed, 0 insertions, 0 deletions