🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.clos
Article #627

Re: Redefining FORMAT

#627
From: Simon Leinen
Date: Wed, 12 Jun 1991 08:19
37 lines
2018 bytes
In <marco.676653088@ipvvis> marco@ipvvis.unipv.it (Marco Ramoni) writes:

Marco> (defmethod format ((tw text-window) string &rest arguments)
Marco>   "Specialized format for text-windows."
Marco>   (print-string-in-window tw (eval `(format nil ,string ,@arguments)))
Marco>   )
   [Produces error under Lucid]
Marco>  [...] can I "Convert the current definition into default method
Marco> directly from my program?"

What you can try is this (probably not portable Common Lisp, but
should work in most implementations):

	(defvar old-format #'format)
	(defmethod new-format (stream format-string &rest args)
	  (apply old-format stream format-string args))
	(defmethod new-format ((tw text-window) string &rest args)
	  ...)
	(setf (symbol-function 'format) #'new-format)

In article <1991Jun11.182622.3303@aplcen.apl.jhu.edu>
hall@aplcen.apl.jhu.edu (Marty Hall) writes:

Marty> Also, as a minor suggestion, try "apply", since "eval" is so
Marty> expensive:
Marty>
Marty> (apply #'format nil string arguments) instead of your "eval" form.

This is a good idea.  Also, the EVAL version has the problem that the
arguments are evaluated *twice*.

Marty> (setf (need-p 'disclaimer) NIL)

(defmethod needp ((who me) (ignore (eql 'disclaimer)))
  (declare (ignore ignore)) nil)
-- 
Simon.
Technical Details
Message-ID: <SIMON.91Jun12101931@liasun1.epfl.ch>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!mcsun!cernvax!chx400!sicsun!disuns2!disuns2.epfl.ch!simon
References: <marco.676653088@ipvvis> <1991Jun11.182622.3303@aplcen.apl.jhu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!mcsun!cernvax!chx400!sicsun!disuns2!disuns2.epfl.ch!simon
From: simon@liasun2.epfl.ch (Simon Leinen)
Newsgroups: comp.lang.clos
Subject: Re: Redefining FORMAT
Message-ID: <SIMON.91Jun12101931@liasun1.epfl.ch>
Date: 12 Jun 91 08:19:31 GMT
References: <marco.676653088@ipvvis> <1991Jun11.182622.3303@aplcen.apl.jhu.edu>
Sender: news@disuns2.epfl.ch
Reply-To: simon@liasun6.epfl.ch
Organization: /users/simon/.organization
Lines: 37
Nntp-Posting-Host: liasun1.epfl.ch
In-reply-to: hall@aplcen.apl.jhu.edu's message of 11 Jun 91 18:26:22 GMT
X-Md4-Signature: d447dec2f34abb44c154a611407d63ca