chickadee » messages » case-variant

(case-variant Type obj variant ....)syntax

where each variant is either of the form

  • (variant-key (arg ...) body ....)

or as last variant

  • (else body ....)

This one macro replaces in algebraic messages the many accessor routines by destructuring the variants via pattern matching. It destructures obj of Type depending on its variants, i.e. matches the variant-key and the argument-list (variant-key (arg ...)) in sequence and invokes the body .... of the first matching pair. The else clause serves as catch-all.

Note that you can alternatively write