CLIM mail archive

[Prev][Next][Index][Thread]

Re: CLIM philosophy wrt to X.



    Date: Mon, 26 Aug 1991 16:15 EDT
    From: kanderso@BBN.COM

	    2.  if the macro was implemented as a closure, this would cons in those
		Common LISP's that still don't stack allocate closures.
  
	  I think with-buffered-output is intended to be a sufficiently high level
	  macro that it is executed infrequently enough compared to the rest of
	  the program that consing a closure is relatively insignificant.
  
      Of the five Lisp implementations I use, none would cause anything to
      be consed for an implementation of WITH-BUFFERED-OUTPUT that writes a
      simple continuation function.
  
    Maybe there is a better way to do it, but i was thinking of something like
    this, which conses 32 bytes in Lucid 4.0:

    (in-package 'user)

    (defmacro with-buffered-output ((stream buffered-p) &body body)
      `(with-buffered-output-internal ,stream ,buffered-p
	#'(lambda (,stream) ,@body)))

    (defun with-buffered-output-internal (stream buffered-p function)
      (let ((buffered buffered-p))
	(declare (special buffered))
	(funcall (the compiled-function function) stream)))

Just for grins, see what this does:

 (defmacro with-buffered-output ((stream buffered-p) &body body)
   `(flet ((with-buffered-output-body (,stream) ,@body))
      (declare (dynamic-extent #'with-buffered-output-body))
      (with-buffered-output-internal
	,stream ,buffered-p #'with-buffered-output-body)))

Also, check to make sure that binding the special variable does not
cons.  You never know...

    (defun foo (stream buffered-p N)
      (flet ((bar (i)))
	(clim::without-interrupts
	(time
	 (dotimes (i N)
	   (with-buffered-output (stream buffered-p)
	     (bar i)))))))


    > (foo nil nil 100)
    Elapsed Real Time = 0.00 seconds
    Total Run Time    = 0.00 seconds
    User Run Time     = 0.00 seconds
    System Run Time   = 0.00 seconds
    Process Page Faults    =          0
    Dynamic Bytes Consed   =          0
    Ephemeral Bytes Consed =      3,208
    NIL
    > (foo nil nil 1000)
    Elapsed Real Time = 0.01 seconds
    Total Run Time    = 0.01 seconds
    User Run Time     = 0.01 seconds
    System Run Time   = 0.00 seconds
    Process Page Faults    =          0
    Dynamic Bytes Consed   =          0
    Ephemeral Bytes Consed =     32,008
    NIL
    > 

0,,


Main Index | Thread Index