The cartesian-product-switch Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The cartesian-product-switch Reference Manual

This is the cartesian-product-switch Reference Manual, version 2.0, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 03:01:15 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Project's home: http://www.hexstreamsoft.com/projects/cartesian-product-switch/


CARTESIAN-PRODUCT-SWITCH is a macro for choosing the appropriate form
to execute according to the combined results of multiple tests. This is a
straightforward and efficient alternative to the convoluted ad-hoc
conditionals one might otherwise resort to.

cartesian-product-switch was born as cartesian-product-case but a
fairly obvious limitation was soon discovered, prompting a redesign
and library name change. Further features and extensibility were also
added.


Here's an example:

(let ((manner :flip) (direction :backward))
  (cartesian-product-switch ((case manner
                               :walk
                               :flip)
                             (case direction
                               :forward
                               :in-place
                               :backward))
    "Walking..."
    (error "Walking in-place is too boring!")
    "Awkwardly walking backwards..."
    "Frontflip!"
    "Jumping in-place."
    "Backflip!"
    (t (error "Don't know how to ~A while going ~A." manner direction))))


Currently supported testclause kinds:
(case ccase ecase typecase ctypecase etypecase if cond svref)

It's also possible to make your own kinds.
Check definitions.lisp in particular for inspiration.
In a nutshell, call (cartesian-product-switch:define operator (args) body),
where BODY must return 3 values:

SELECTION-FORM:
A form evaluating to a non-negative integer less than SELECTION-COUNT.

SELECTION-COUNT:
The number of possibilities this testclause introduces.

DEFAULTP:
If true, then the SELECTION-FORM can evaluate to NIL to trigger the "default".


This library is in the Public Domain.
See the UNLICENSE file for details.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cartesian-product-switch

Author

Jean-Philippe Paradis <hexstream@gmail.com>

License

Public Domain

Description

CARTESIAN-PRODUCT-SWITCH is a macro for choosing the appropriate form to execute according to the combined results of multiple tests. This is a straightforward and efficient alternative to the convoluted ad-hoc conditionals one might otherwise resort to.

Version

2.0

Dependency

map-bind

Source

cartesian-product-switch.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 cartesian-product-switch.asd

Location

cartesian-product-switch.asd

Systems

cartesian-product-switch (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 cartesian-product-switch/package.lisp

Parent

cartesian-product-switch (system)

Location

package.lisp

Packages

cartesian-product-switch


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.3 cartesian-product-switch/info.lisp

Dependency

package.lisp (file)

Parent

cartesian-product-switch (system)

Location

info.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.4 cartesian-product-switch/definitions.lisp

Dependency

info.lisp (file)

Parent

cartesian-product-switch (system)

Location

definitions.lisp

Internal Definitions

%map-with-index (function)


Previous: , Up: Lisp files   [Contents][Index]

3.1.5 cartesian-product-switch/main.lisp

Dependency

definitions.lisp (file)

Parent

cartesian-product-switch (system)

Location

main.lisp

Exported Definitions

cartesian-product-switch (macro)

Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 cartesian-product-switch

Source

package.lisp (file)

Nickname

cp-switch

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Macros

Macro: cartesian-product-switch (&rest TESTCLAUSES) &body CLAUSES
Package

cartesian-product-switch

Source

main.lisp (file)

Macro: define NAME MACRO-LAMBDA-LIST &body BODY
Package

cartesian-product-switch

Source

info.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: ensure NAME LAMBDA-LIST EXPANDER &rest KEYS &key CLASS &allow-other-keys
Package

cartesian-product-switch

Source

info.lisp (file)

Function: expand TESTCLAUSE &optional ENV
Package

cartesian-product-switch

Source

info.lisp (file)

Function: locate TESTCLAUSE-NAME &key ERRORP
Package

cartesian-product-switch

Source

info.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Generic functions

Generic Function: expander OBJECT
Package

cartesian-product-switch

Source

info.lisp (file)

Methods
Method: expander (STANDARD-INFO standard-info)

automatically generated reader method

Generic Function: lambda-list OBJECT
Package

cartesian-product-switch

Source

info.lisp (file)

Methods
Method: lambda-list (STANDARD-INFO standard-info)

automatically generated reader method

Generic Function: name OBJECT
Package

cartesian-product-switch

Source

info.lisp (file)

Methods
Method: name (STANDARD-INFO standard-info)

automatically generated reader method


Previous: , Up: Exported definitions   [Contents][Index]

5.1.4 Classes

Class: info ()
Package

cartesian-product-switch

Source

info.lisp (file)

Direct superclasses

standard-object (class)

Direct subclasses

standard-info (class)

Class: standard-info ()
Package

cartesian-product-switch

Source

info.lisp (file)

Direct superclasses

info (class)

Direct methods
Direct slots
Slot: %name
Type

cartesian-product-switch::testclause-name

Initargs

:name

Readers

name (generic function)

Slot: %lambda-list
Type

list

Initargs

:lambda-list

Readers

lambda-list (generic function)

Slot: %expander
Type

(or function symbol)

Initargs

:expander

Readers

expander (generic function)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *infos*
Package

cartesian-product-switch

Source

info.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Functions

Function: %check-expected-operator ACTUAL EXPECTED
Package

cartesian-product-switch

Source

info.lisp (file)

Function: %compute-factors SELECTION-COUNTS
Package

cartesian-product-switch

Source

main.lisp (file)

Function: %compute-selection-forms TESTCLAUSES ENV ELSE-TAG
Package

cartesian-product-switch

Source

main.lisp (file)

Function: %expand-linearize TESTCLAUSES ENV
Package

cartesian-product-switch

Source

main.lisp (file)

Function: %extract-&environment MACRO-LAMBDA-LIST
Package

cartesian-product-switch

Source

info.lisp (file)

Function: (setf %locate) NEW TESTCLAUSE-NAME &key ERRORP
Package

cartesian-product-switch

Source

info.lisp (file)

Function: %make-expander NAME MACRO-LAMBDA-LIST BODY
Package

cartesian-product-switch

Source

info.lisp (file)

Function: %map-with-index MAPPING-FUNCTION FUNCTION ARG
Package

cartesian-product-switch

Source

definitions.lisp (file)

Function: %remove-keys KEYS PLIST
Package

cartesian-product-switch

Source

info.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Types

Type: testclause-name ()
Package

cartesian-product-switch

Source

info.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L  
Index Entry  Section

C
cartesian-product-switch.asd: The cartesian-product-switch<dot>asd file
cartesian-product-switch/definitions.lisp: The cartesian-product-switch/definitions<dot>lisp file
cartesian-product-switch/info.lisp: The cartesian-product-switch/info<dot>lisp file
cartesian-product-switch/main.lisp: The cartesian-product-switch/main<dot>lisp file
cartesian-product-switch/package.lisp: The cartesian-product-switch/package<dot>lisp file

F
File, Lisp, cartesian-product-switch.asd: The cartesian-product-switch<dot>asd file
File, Lisp, cartesian-product-switch/definitions.lisp: The cartesian-product-switch/definitions<dot>lisp file
File, Lisp, cartesian-product-switch/info.lisp: The cartesian-product-switch/info<dot>lisp file
File, Lisp, cartesian-product-switch/main.lisp: The cartesian-product-switch/main<dot>lisp file
File, Lisp, cartesian-product-switch/package.lisp: The cartesian-product-switch/package<dot>lisp file

L
Lisp File, cartesian-product-switch.asd: The cartesian-product-switch<dot>asd file
Lisp File, cartesian-product-switch/definitions.lisp: The cartesian-product-switch/definitions<dot>lisp file
Lisp File, cartesian-product-switch/info.lisp: The cartesian-product-switch/info<dot>lisp file
Lisp File, cartesian-product-switch/main.lisp: The cartesian-product-switch/main<dot>lisp file
Lisp File, cartesian-product-switch/package.lisp: The cartesian-product-switch/package<dot>lisp file

Jump to:   C   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   %   (  
C   D   E   F   G   L   M   N  
Index Entry  Section

%
%check-expected-operator: Internal functions
%compute-factors: Internal functions
%compute-selection-forms: Internal functions
%expand-linearize: Internal functions
%extract-&environment: Internal functions
%make-expander: Internal functions
%map-with-index: Internal functions
%remove-keys: Internal functions

(
(setf %locate): Internal functions

C
cartesian-product-switch: Exported macros

D
define: Exported macros

E
ensure: Exported functions
expand: Exported functions
expander: Exported generic functions
expander: Exported generic functions

F
Function, %check-expected-operator: Internal functions
Function, %compute-factors: Internal functions
Function, %compute-selection-forms: Internal functions
Function, %expand-linearize: Internal functions
Function, %extract-&environment: Internal functions
Function, %make-expander: Internal functions
Function, %map-with-index: Internal functions
Function, %remove-keys: Internal functions
Function, (setf %locate): Internal functions
Function, ensure: Exported functions
Function, expand: Exported functions
Function, locate: Exported functions

G
Generic Function, expander: Exported generic functions
Generic Function, lambda-list: Exported generic functions
Generic Function, name: Exported generic functions

L
lambda-list: Exported generic functions
lambda-list: Exported generic functions
locate: Exported functions

M
Macro, cartesian-product-switch: Exported macros
Macro, define: Exported macros
Method, expander: Exported generic functions
Method, lambda-list: Exported generic functions
Method, name: Exported generic functions

N
name: Exported generic functions
name: Exported generic functions

Jump to:   %   (  
C   D   E   F   G   L   M   N  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   %   *  
S  
Index Entry  Section

%
%expander: Exported classes
%lambda-list: Exported classes
%name: Exported classes

*
*infos*: Internal special variables

S
Slot, %expander: Exported classes
Slot, %lambda-list: Exported classes
Slot, %name: Exported classes
Special Variable, *infos*: Internal special variables

Jump to:   %   *  
S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   I   P   S   T  
Index Entry  Section

C
cartesian-product-switch: The cartesian-product-switch system
cartesian-product-switch: The cartesian-product-switch package
Class, info: Exported classes
Class, standard-info: Exported classes

I
info: Exported classes

P
Package, cartesian-product-switch: The cartesian-product-switch package

S
standard-info: Exported classes
System, cartesian-product-switch: The cartesian-product-switch system

T
testclause-name: Internal types
Type, testclause-name: Internal types

Jump to:   C   I   P   S   T