diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-12-18 20:50:07 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-12-18 20:50:07 -0800 |
commit | ddb0330c904fac025a6f50219937b204c4c880c7 (patch) | |
tree | dd1096793bf0fa30fdb683523e1a9a7edb1a7d70 /share | |
parent | f0228c233a9b295c828dc4023f84b092eb8bee51 (diff) | |
download | txr-ddb0330c904fac025a6f50219937b204c4c880c7.tar.gz txr-ddb0330c904fac025a6f50219937b204c4c880c7.tar.bz2 txr-ddb0330c904fac025a6f50219937b204c4c880c7.zip |
New condlet macro; small change to iflet/whenlet.
* eval.c (me_iflet_whenlet): Allow the test form
to be an atomic expression instead of bindings.
This allows iflet to be used as the sole target
construct of condlet, while allowing condlet to
have a fallback clause with t. It also means that
an empty list of bindings is allowed (since it
is the atom nil).
* lisplib.c (ifa_set_entries): Add "condlet" to
the autoload names for the ifa module. That's
where we are adding condlet.
* share/txr/stdlib/ifa.tl (sys:if-to-cond): New
macro expander helper function, generalizing the writing
cond-like macros based on if-like operators.
(conda): Rewritten using sys:if-to-cond.
(condlet): New macro.
* txr.1: Documented change in iflet/whenlet.
Documented condlet.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/ifa.tl | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/share/txr/stdlib/ifa.tl b/share/txr/stdlib/ifa.tl index cefb38eb..42b4d99c 100644 --- a/share/txr/stdlib/ifa.tl +++ b/share/txr/stdlib/ifa.tl @@ -65,9 +65,16 @@ (if (,sym ,*(if (eq 'dwim sym) ^(,(second test))) ,*temps) ,then ,else))))))))) +(macro-time + (defun sys:if-to-cond (if-oper cond-oper pairs) + (tree-case pairs + (((test . forms) . rest) ^(,if-oper ,test (progn ,*forms) + (,cond-oper ,*rest))) + (() ()) + (else (throwf 'eval-error "~s: bad syntax: ~s" cond-oper pairs))))) + (defmacro conda (. pairs) - (tree-case pairs - (((test . forms) . rest) ^(ifa ,test (progn ,*forms) - (conda ,*rest))) - (() ()) - (else (throwf 'eval-error "conda: bad syntax: ~s" pairs)))) + (sys:if-to-cond 'ifa 'conda pairs)) + +(defmacro condlet (. pairs) + (sys:if-to-cond 'iflet 'condlet pairs)) |