Subject: Re: Special variables, style and packages
From: (Rob Warnock)
Date: 2 Jul 2002 04:04:29 GMT
Newsgroups: comp.lang.lisp
Message-ID: <afr8od$5ho4b$>
gary <> wrote:
| ...dialog boxes for data entry.  I have over 90 data screens...
| (defvar *example-pane* 
|    (make-instance 
|       'capi:column-layout
|       <.... about 40 lines of layout instructions ....> ))
| I feel queasy having so many special variables around.

You should feel queasy.  What about defining a single alist or
hash table that contains all your examples?  E.g. [untested]:

	(defvar *capi-examples* (make-hash-table))

	; then lots of these:
	(setf (gethash 'example-pane *capi-examples*)
	    <...layout instructions...> ))

	...additional SETFs as needed...

	; abstract the lookup (and error check)
	(defun get-capi-example (name)
	  (let ((example (gethash 'example-pane *capi-examples*)))
	    (unless example
	      (error "get-capi-example: example screen not found:" name))

Then when you need the "example-pane" again, it's easily found:

	(let ((pane (get-capi-example 'example-pane))) something with pane...)


p.s. Note: I originally wrote the above with keywords (":example-pane")
instead of symbols in the current package, but there have been comments
here on the list about not polluting the KEYWORD packages with such stuff.
You can do it either way. Or even make a single separate "CAPI-EXAMPLES"
package with the global hash table name and the hash keys in it, whatever.
Just be warned that I'm not an experienced enough CL programmer to be
giving advice on matters of style at that level...  ;-}

Rob Warnock, 30-3-510		<>
SGI Network Engineering		<>
1600 Amphitheatre Pkwy.		Phone: 650-933-1673
Mountain View, CA  94043	PP-ASEL-IA

[Note: and aren't for humans ]