help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

question to `case'


From: Klaus Berndl
Subject: question to `case'
Date: 23 Mar 2005 13:39:36 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Can i use variables for the keys of the KEY-CLAUSES?

Example:

This is a case with two keys 1 and 2 which works very well:

,----
| (case (tree-node->type node)
|   (1
|    (nth 2 (tree-node->data node)))
|   (2
|    (ignore-errors (semantic-tag-class (tree-node->data node))))
|   (otherwise nil))
`----


My question: I would prefer to define some constants, so e.g.

,----
| (defconst my-bucket-node-type 1)
| (defconst my-tag-node-type 2)
`----

And then i want to use these two constants as keys in this case
instead of this hard-coded numbers 1 and 2, so for example something
like:

,----
| (case (tree-node->type node)
|   (my-bucket-node-type
|    (nth 2 (tree-node->data node)))
|   (my-tag-node-type
|    (ignore-errors (semantic-tag-class (tree-node->data node))))
|   (otherwise nil))
`----

whereas my-bucket-node-type and my-tag-node-type should be evaluated to
the const values...

Of course the notation above can not work but my question is: What is right
notation?

Thanks a lot in advance!
Klaus

-- 
Klaus Berndl                    mailto: klaus.berndl@sdm.de
sd&m AG                         http://www.sdm.de
software design & management    
Carl-Wery-Str. 42, 81739 Muenchen, Germany
Tel +49 89 63812-392, Fax -220


reply via email to

[Prev in Thread] Current Thread [Next in Thread]