[alexandria-devel] Re: Review cycle 2: SWITCH, ESCWITCH, and CSWITCH
Tobias C. Rittweiler
tcr at freebits.de
Wed Jun 11 15:43:01 UTC 2008
"Nikodemus Siivola" <nikodemus at random-state.net> writes:
> Re. expanding into COND: I think the API is the important bit. If we
> are able to figure out that something else is more efficient, then we
> can expand into something else -- COND is an implementation detail.
It isn't about expanding into COND per se, but that the clause-keys are
evaluated. Both behaviours are useful, but the name SWITCH connotes the
non-evaluating behaviour, IMO. We could add another macro that works
like SWITCH works now, but is called SELECT.
> Here are the new (proposed) docstrings:
>
> macro switch (&whole whole (keyform &key (test #'eql) key) &body clauses)
> "Conditionally executes one of the clauses, and returns its values. KEYFORM
> is first evaluated, and if KEY is given and non-null, it is used to extract a
> comparison value from the result of evaluating KEYFORM.
"KEYFORM is first evaluated, and if KEY is given and non-null (in which
case it must evaluate to a function designator), it's applied to the
result of evaluating KEYFORM, to extract the comparasion value. If KEY
is not given, the result of evaluating KEYFORM itself is used as
comparasion value."
"TEST must evaluate to a function designator of two arguments."
> macro eswitch (&whole whole (keyform &key (test #'eql) key) &body clauses)
> "Conditionally executes one of the clauses, and returns its values. KEYFORM
> is first evaluated, and if KEY is given and non-null, it is used to extract a
> comparison value from the result of evaluating KEYFORM.
>
I think ESWITCH, and CSWITCH shouldn't repeat everything that already
said in SWITCH, but should reference SWITCH, and explain how they
differ, i.e.
"ESWITCH works exactly like SWITCH except if no clause matches, an error
is signalled."
-T.
More information about the alexandria-devel
mailing list