diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-11-12 20:05:42 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-11-12 20:05:42 -0800 |
commit | 7057603b4da78bb27e7688a9d74de6025132dbbc (patch) | |
tree | 13cf400d1ae922fc2ec1e9befc15fce271a95ea4 /txr.1 | |
parent | b530453f8e0331955b40c741a3b5dcb4bf6084d8 (diff) | |
download | txr-7057603b4da78bb27e7688a9d74de6025132dbbc.tar.gz txr-7057603b4da78bb27e7688a9d74de6025132dbbc.tar.bz2 txr-7057603b4da78bb27e7688a9d74de6025132dbbc.zip |
Introduce case{q,ql,qual}* macros which eval keys.
* eval.c (caseq_star_s, caseql_star_s, casequal_star_s):
New symbol variables.
(me_case): Implement new macro semantics.
(eval_init): Initialize new symbol variables, and
register the symbols to the me_case macro expander.
* tests/sock-common.tl (local-addr): This function
depends on the old broken caseql semantics which
evaluate keys. Using caseql* makes it work again.
* txr.1: Document case{q,ql,qual}* macros.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 75 |
1 files changed, 75 insertions, 0 deletions
@@ -13243,6 +13243,81 @@ uses ...) .cble +.coNP Macros @, caseq* @ caseql* and @ casequal* +.synb +.mets (caseq* < test-form << normal-clause * <> [ else-clause ]) +.mets (caseql* < test-form << normal-clause * <> [ else-clause ]) +.mets (casequal* < test-form << normal-clause * <> [ else-clause ]) +.syne +.desc +The +.codn caseq* , +.codn caseql* , +and +.code casequal* +macros are similar to the macros +.codn caseq , +.codn caseql , +and +.codn casequal , +differing from them in only the following regard. The +.metn normal-clause , +of these macros has the form +.cblk +.mets >> ( evaluated-key << form *) +.cble +where +.code evaluated-key +is either an atom, which is evaluated to produce a key, or else +else a compound form, whose elements are evaluated as forms, producing +multiple keys. This evaluation takes place at macro-expansion time, +in the dynamic environment. + +The +.meta else-clause +works the same way under these macros as under +.code caseq +.IR "et al" . + +Note that although in a +.metn normal-clause , +.meta evaluated-key +must not be the atom +.codn t , +there is no restriction against it being +an atom which evaluates to +.code t. +In this situation, the value +.code t +has no special meaning. + +The +.meta evaluated-key +expressions are evaluated in the order in which they appear in +the construct, at the time the +.codn caseq* , +.code caseql* +or +.code casequal* +macro is expanded. + +Note: these macros allow the use of variables and global symbol +macros as case keys. + +.TP* Example: + +.cblk + (defvarl red 0) + (defvarl green 1) + (defvarl blue 2) + + (let ((color blue)) + (caseql* color + (red "hot") + ((green blue) "cool"))) + --> "cool" +.cble + .coNP Operator/function @ if .synb .mets (if < cond < t-form <> [ e-form ]) |