CLIM mail archive

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

Re: CLIM philosophy wrt to X.



  	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)))

(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,,

References:

Main Index | Thread Index