Re: Using "internal" macros of a CL implementation
- From: Victor Kryukov <victor.kryukov+news@xxxxxxxxx>
- Date: Sun, 29 Oct 2006 14:32:06 -0600
Ken Tilton <kentilton@xxxxxxxxx> writes:
Victor Kryukov wrote:
Hello group,COND.
I've the following question: I want to define macro case-string, which
behaves exactly like case, only using string-equal instead of eql.
I've looked up definition of case in SBCL[*], and realized that my
task is as simple as
(defmacro case-string (keyform &body cases)
(case-body 'case keyform cases t 'string-equal nil nil nil))
Let me be more precise here. I do understand how to use COND to
achieve what I need. I just want more useful macro, so that
(let ((keyform "test"))
(case-string keyform
("test1" 'test1)
(("test2" "test3") 'test2-or-3)
(("test" "test4") 'test-or-4)))
would evaluate to TEST-OR-4. Of course, you can do that simply by
using COND, as Ken suggested:
(cond
((string= keyform "test1") 'test1)
((member keyform '("test2" "test3") :test #'string=) 'test2-or-3)
((member keyform '("test" "test4") :test #'string=) 'test-or-4))
and is seems not that hard to write case-string macro which translates
first snippet to the second. I've just noticed that similar
functionality already existed in SBCL core - e.g. case is really
similar, it's only uses 'eql instead of string=, and is defined with
help of internal macro case-body; my question was how one can possibly
access such macros (even in non-portable way) to avoid duplicating
existing functionality.
Victor.
.
- Follow-Ups:
- Re: Using "internal" macros of a CL implementation
- From: Pascal Costanza
- Re: Using "internal" macros of a CL implementation
- References:
- Using "internal" macros of a CL implementation
- From: Victor Kryukov
- Re: Using "internal" macros of a CL implementation
- From: Ken Tilton
- Using "internal" macros of a CL implementation
- Prev by Date: Re: allegro cl installer -- A.I built in, all the way DOWN
- Next by Date: Re: newbie request for lisp webapp project idea
- Previous by thread: Re: Using "internal" macros of a CL implementation
- Next by thread: Re: Using "internal" macros of a CL implementation
- Index(es):
Relevant Pages
|