Re: dspecs for progns?
Just pinging this again since I haven't heard anything. I've got some
library code most of whose functions are defined via macros, and it
would be very nice to be able to use "Find Source" with them.
Thanks in advance,
On Thu, Feb 26, 2009 at 4:19 PM, Joshua TAYLOR <tayloj@cs.rpi.edu> wrote:
> Hello all,
>
> If I have a macro that expands into a PROGN with some DEFUNS within,
> what's the appropriate way to make those DEFUNs findable?
> Particularly, they aren't part of some bigger defined thing, like the
> MAKE-* and *-SLOT functions in a DEFSTRUCT might be considered to be.
> E.g., if I was making functions to trim a certain kinds of character
> classes, I might write a macro:
>
> (defmacro define-trimmers (kind bag)
> (flet ((ics (&rest args)
> (intern (apply 'concatenate 'string (mapcar 'string args)))))
> (let ((stk (ics '#:string-trim- kind))
> (stlk (ics '#:string-trim-left- kind))
> (strk (ics '#:string-trim-right- kind)))
> `(progn
> (defun ,stk (string) (string-trim ',bag string))
> (defun ,stlk (string) (string-left-trim ',bag string))
> (defun ,strk (string) (string-right-trim ',bag string))))))
>
> so that
>
> (define-trimmers vowel "aeiou")
>
> expands into
>
> (PROGN
> (DEFUN STRING-TRIM-VOWEL (STRING) (STRING-TRIM '"aeiou" STRING))
> (DEFUN STRING-TRIM-LEFT-VOWEL (STRING) (STRING-LEFT-TRIM '"aeiou" STRING))
> (DEFUN STRING-TRIM-RIGHT-VOWEL (STRING) (STRING-RIGHT-TRIM '"aeiou" STRING)))
>
> Since I'm not defining some bigger thing to which these functions
> `belong', I'm not sure what the second argument to DSPEC:DEF would be.
> I recognize that I /can/ use the top-level form, e.g., use
>
> `(dspec:def (define-trimmers ,kind) ; note JUST ,kind
> (defun ,stk (string) (string-trim ',bag string))
> (defun ,stlk (string) (string-left-trim ',bag string))
> (defun ,strk (string) (string-right-trim ',bag string)))
>
> without having to define anything about define-trimmers. I can use
> "Find Definition" if I do this. But this doesn't work if there's more
> than one significant argument to the macro. E.g., if I'd tried to do
>
> `(dspec:def (define-trimmers ,kind ,bag) ; note ,kind AND ,bag
> (defun ,stk (string) (string-trim ',bag string))
> (defun ,stlk (string) (string-left-trim ',bag string))
> (defun ,strk (string) (string-right-trim ',bag string)))
>
> then I'd get in the minibuffer:
>
> Cannot find (DEFINE-TRIMMERS VOWEL "aeiou") in defns.lisp
>
> I think I'm missing something simple here—hopefully someone can chime
> in and point me to what it is.
>
> Thanks in advance,
> //JT
>
--
=====================
Joshua Taylor
tayloj@cs.rpi.edu, jtaylor@alum.rpi.edu
"A lot of good things went down one time,
back in the goodle days."
John Hartford