<HTML><BODY><P>I compared parameterize with lexical var<BR>----<BR>> (require rackunit)<BR>> (define my-parameter (make-parameter (box 0)))<BR>> (time <BR> (parameterize ([my-parameter (box 0)]) <BR> (for ([x (in-range 10000000)]) <BR> (set-box! (my-parameter) <BR> (add1 (unbox (my-parameter))))) <BR> (check-equal? (unbox (my-parameter)) 10000000))) </P>
<P>cpu time: 3578 real time: 3610 gc time: 0<BR>> (time <BR> (let ([my-parameter (box 0)]) <BR> (for ([x (in-range 10000000)]) <BR> (set-box! my-parameter <BR> (add1 (unbox my-parameter)))) <BR> (check-equal? (unbox my-parameter) 10000000))) </P>
<P>cpu time: 47 real time: 47 gc time: 0<BR>----<BR><BR>100 times difference!<BR><BR>The same experiment with Common Lisp (SBCL):<BR>----<BR>CL-USER> (setf *a* (list 0))<BR>(0)<BR>CL-USER> (time (progn (loop :for i :from 0 :below 10000000<BR> :do (setf (car *a*) (+ 1 (car *a*)))) (= (car *a*) 10000000)))<BR>Evaluation took:<BR> 0.063 seconds of real time<BR> 0.062500 seconds of total run time (0.062500 user, 0.000000 system)<BR> 98.41% CPU<BR> 172,464,541 processor cycles<BR> 0 bytes consed<BR> <BR>T<BR>CL-USER> (let ((a (list 0))) (time (loop :for i :from 0 :below 10000000<BR> :do (setf (car a) (+ 1 (car a))))) (= (car a) 10000000))<BR> <BR>Evaluation took:<BR> 0.047 seconds of real time<BR> 0.046875 seconds of total run time (0.046875 user, 0.000000 system)<BR> 100.00% CPU<BR> 132,098,942 processor cycles<BR> 0 bytes consed<BR> <BR>T<BR>----<BR>Only 1.5 times.<BR><BR>Is it undesirable to use parameterize as replacement for common lisp special variables? What is it designed for then?<BR><BR><BR>-- <BR>Roman Klochkov</P></BODY></HTML>