[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
For the record.
- To: KMP at MIT-MC
- Subject: For the record.
- From: George J. Carrette <GJC at MIT-MC>
- Date: Thu, 25 Sep 80 16:07:00 GMT
- Cc: BUG-LISP at MIT-MC, GSB at MIT-MC, JONL at MIT-MC, ALAN at MIT-MC
- Original-date: 25 September 1980 12:07-EDT
If anyone wants to use something which has the functionality of
*FUNCTION, yet compiles into good code, there is LIBMAX;CLOSE >
I'll give a short example,
(defclosure stack (com arg)
((sp 0) (array (*array nil t 50)) (dim 50)
(undeflow (make-undeflow)) (overflow (make-overflow)))
(caseq com
(null (= sp 0))
(pop
(setq sp (1- sp))
(if (= sp 0) (call underflow self))
(arraycall t array sp))
(push
(setq sp (1+ sp))
(if (= sp dim) (call overflow self))
(setf (arraycall t array sp) arg)
SELF)))
(defclosure overflow (master) ((more-inc 10) (more-limit 5))
(if (= more-limit 0) (barf))
(setq more-limit (1- more-limit))
(IN-ENV-OF-STACK MASTER
; lexical scoping of variables of course!
; so if we want the variables of somebody we have
; to be explicit.
(setq dim (+ dim more-inc))
(*rearray array dim)))
(setq s (make-stack))
I use a macro CALL, so that calling these guys can be open compiled, (subrcall).
That way I can use them for clipping-streams, 3d-transformation-streams,
and other graphics applications. If you want to go through FUNCALL
you can, just by setting up the USERHUNK things. However, I found
FUNCALL to be too slow, changing the whole Programming Style.
(Actually this was using the general CLASS stuff to do the
dispatching, I don't know how much faster you can make it by writing
your own hunk-dispatcher in midas).
-gjc