From: Kaz K. <ka...@as...> - 2004-09-20 18:14:17
|
On Mon, 20 Sep 2004, Reini Urban wrote: > I need the unquote-splice facility in the km reasoner. > http://www.cs.utexas.edu/users/mfkb/km.html > > I've looked at http://users.footprints.net/~kaz/clisp-backquote-patch.html, > which describes the patch, which changed the clisp behaviour. > > Sorry, but I forgot almost all of my macro knowledge. > How to do call unquote-splice and friends in clisp now as macro/function? > > This is the KM assoc list, which will be applied on the various symbols: > > (defconstant *special-symbol-alist* > '( (quote "'") > (function "#'") > (unquote "#,") > (#-clisp unquote-splice #+clisp unquote-splice "#@") > (#+allegro excl::backquote #-allegro backquote "`") > (#+allegro excl::bq-comma #-allegro bq-comma ",") ; I'm not sure > of the non-Allegro implementation > (#+allegro excl::bq-comma-atsign #-allegro bq-comma-atsign ",@") )) > > The system package is locked, so I have no access. (Do I?) > Are my clisp workarounds correct? Hi Reini, Not sure what your software is trying to do, but be aware that the splice operators are not functions or macros. They are just syntax that can occur in a backquote template. CLISP's backquote implementation is a macro which looks for these operators and translates them into code. The following two forms are equivalent in CLISP: `(,foo ,@bar) (system::backquote ((system::unquote foo) (system::splice bar))) SYSTEM::BACKQUOTE is a macro which interprets the object ((SYSTEM::UNQUOTE FOO) (SYSTEM::SPLICE BAR)) and handles the unquotes and splices within. SYSTEM::UNQUOTE and SYSTEM::SPLICE are not facilities that are somehow available separately, but they do give us a symbolic syntax that we can generate programmatically without the use of the elements of the backquote syntax. The whole point is that you have a target data structure for writing the source code of backquote expressions, rather than just a target character-level syntax that must be processed by the reader. To make these operators do anything, they must be correctly placed into a a form which represents a complete SYSTEM::BACKQUOTE macro call, and that form must be evaluated. > #+clisp > (defmacro unquote-splice (form) > `(,@ form)) Not sure what the intent is here. All this does is evaluate the form, so a good name for this macro would be EVAL, if that symbol weren't taken already. The effect is like that of (APPEND FORM) for any given form. If the FORM produces an atom, then that atom is returned. If it produces a list, then that list is returned. -- Meta-CVS: the working replacement for CVS that has been stable for two years. It versions the directory structure, symbolic links and execute permissions. It figures out renaming on import. Plus it babysits the kids and does light housekeeping! http://freshmeat.net/projects/mcvs |