[alexandria-devel] Re: Review cycle 2: SWITCH, ESCWITCH, and CSWITCH

Nikodemus Siivola nikodemus at random-state.net
Mon Jul 7 09:15:26 UTC 2008


On Wed, Jun 11, 2008 at 6:43 PM, Tobias C. Rittweiler <tcr at freebits.de> wrote:
> "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.

On reflection, I think you are right.

Here's my next take (same docstring for all three.)

  "Conditionally executes one of the clauses, and returns its values.

Clauses are of the form:

  (CLAUSE-KEYS &BODY FORMS)

CLAUSE-KEYS is a designator for a list of objects. Symbols T and OTHERWISE may
not be used as the CLAUSE-KEYS designator: to refer to these symbols by
themselves as CLAUSE-KEYS, designators \(T) and \(OTHERWISE) must be used.

KEYFORM is evaluated to produce a comparison value. Each of the CLAUSES is the
considered in turn. If

 (MEMBER <COMPARISON-VALUE> 'CLAUSE-KEYS-LIST :TEST TEST :KEY KEY)

is true, the FORMS in that clause are evaluated as in implicit PROGN, and the
values returned as the value of the SWITCH, CSWITCH, or ESWITCH form.

Clauses with T or OTHERWISE as CLAUSE-KEYS are considered to always match.
Such clause must be tha last clause.

If no clause matches, SWITCH returns NIL, CSWITCH signals a continuable error,
and ESWITCH signals an error."

Cheers,

 -- Nikodemus



More information about the alexandria-devel mailing list