From: Adam W. <li...@co...> - 2005-02-19 03:39:10
|
On Fri, 18 Feb 2005 10:25:51 -0800, Peter Graves wrote: > On Sat, 19 Feb 2005 at 01:39:15 +1300, Adam Warner wrote: >> CL-USER(1): (macro-function 'cond) >> #<FUNCTION {153B2CB}> >> CL-USER(2): (setf (macro-function 'c) (macro-function 'cond)) >> Debugger invoked on condition of type UNDEFINED-FUNCTION: >> The function (SETF MACRO-FUNCTION) is undefined. >> >> This example should make the COND macro accessible as C. >> >> <http://www.lispworks.com/documentation/HyperSpec/Body/f_macro_.htm> > > Fixed. Great stuff, thanks!!! From my perspective the only significant known omission remaining is pretty printing of structures (i.e. :print-function and :print-object, plus :constructor issues).* I fully understand fixing this depends upon the eventual rewrite of the pretty printer. I can use the SETF MACRO-FUNCTION functionality to clone many COMMON-LISP macros in a case preserving package. Consider this lowercase lisp (lcl) package: (make-package "lcl" :use '()) (setf (macro-function '|lcl|::|cond|) (macro-function 'cl:cond)) (in-package "lcl") (|cond| (1 "true")) => "true" Thanks again, Adam * That is (just for reference): CL-USER(1): (defstruct (test1 (:print-object print-test1)) st) TEST1 CL-USER(2): (defun print-test1 (struct stream) (write-string "#<Hello, Peter!>" stream)) PRINT-TEST1 CL-USER(3): (make-test1) #S(TEST1 :ST NIL) [output should be #<Hello, Peter!>] CL-USER(1): (defstruct (test2 (:constructor new-test2)) st) TEST1 CL-USER(2): (new-test2) #S(TEST2 :ST NIL) CL-USER(3): (read-from-string "#S(TEST2 :ST NIL)") Debugger invoked on condition of type UNDEFINED-FUNCTION: The function MAKE-TEST2 is undefined. [That's because the constructor is actually NEW-TEST2] |