Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!travelers.mail.cornell.edu!news.kei.com!simtel!col.hp.com!news.corp.hp.com!isonews.bbn.hp.com!hpbbrd!jensk
From: jensk@hpbbn.bbn.hp.com (Jens Kilian)
Subject: Re: Enumerated symbols in lisp
Sender: news@hpbbrd.bbn.hp.com (News System)
Message-ID: <D6ntx6.IEr@hpbbrd.bbn.hp.com>
Date: Fri, 7 Apr 1995 10:17:29 GMT
References: <3lh364$fs6@erinews.ericsson.se> <pch-3103952152540001@198.3.157.73> <3loct1$6og@erinews.ericsson.se>
Organization: HP Mechanical Design Division
X-Newsreader: TIN [version 1.2 PL2]
X-Disclaimer: I do not speak for HP, I only *work* here.
Lines: 29

Mikael Wittberg (etxwitt@garbo.ericsson.se) wrote:
> But in a few cases, like the one above, I would also like to be
> able to use a more efficient programming construct. I am really
> only after a way to solve this problem in lisp, even if the possible
> solutions are not very easily expressed in lisp.

In KCL (which is now GNU Common Lisp), you can get efficient code by using CASE
and dispatching on FIXNUMs.  CASE statements such as this are converted to
C 'switch' statements by the KCL compiler:

	(defun dispatcher (selector)
	  (declare (fixnum selector))

	  (case
	    (0
              (do-stuff-for-0-case))

	    ((1 2)
	      (do-stuff-for-1-and-2))

	    (42
	      (print *answer*))

	    (otherwise
	      (foo))))

Hope this helps,

	Jens.
