How to clean up Command Reactors?

Alexander V. Koshman

Usenet Archive
Joined
Dec 16, 2003
Messages
61
Reaction score
0
Hello to every living soul here!

I would ask how I must clean up Command reactors
in every particular .lsp file correctly?

Example:
1. Create the action reactor:

(vl-load-com)
(setq command1-start-rr (VLR-Command-reactor nil '((:VLR-commandWillStart .
command1-start))))

2. Make the action function:

(defun command1-start ( calling-reactor commandInfo / ) ...
) ; - 'defun'

3. Create the cleaning reactor:

(setq close-clean-rr (VLR-DWG-Reactor nil '((:vlr-BeginClose .
close-clean))))

4. Question: What I have to write in cleaning function?

(defun close-clean
(vlr-remove command1-start-rr)
(setq command1-start-rr nil)
(setq command1-start nil)
) ; - 'defun'

And how about the Cleaning reactor itself?
Do I have to clean it too???

Thank you in advance!
 
Off the top of my head...
For only :vlr-command-reactor, use:
(defun close-clean (Reacctor Info)
(mapcar 'vlr-remove (mapcar 'cadr (vlr-reactors :vlr-command-reactor))) )
For everything, use:

(defun close-clean (Reactor Info)
(vlr-remove-all)
)
As to clearing out symbol names, it only matters when in SDI and LISPINIT is set to 0.
 
John,
Excellent point about lispinit and sdi.

Alexander,
Don't miss another important point about John's
post. Callback functions, even for cleaning up,
must have arguments in accordance with the
specifications in the lisp documentation.

Unless writing a separate namespace application,
I prefer not to call (vlr-remove-all) or to use
the method John' used for cleaning up command
reactors because I believe each application should
be responsible for cleaning up after itself. There
could be more than one beginclose reactors for
example. There is no guarantee that the other
beginclose reactors would execute properly if
one application decided to pre-empt them all.

I sometimes use (setq reactors (vlr-remove-all))
when I want to temporarily disable other reactors
and then add them back with (vlr-add reactors)
to re-enable them.

A cleanup reactor can also disable itself while it is
operating.
 
Thanks, Doug, for adding the sage corrections. I had rushed an answer that needed more explantion.
 
Thank your both John and Doug!
For only :vlr-command-reactor, use:
(defun close-clean (Reacctor Info)
(mapcar 'vlr-remove (mapcar 'cadr (vlr-reactors :vlr-command-reactor)))
)

Cool! I like MAPCAR more and more!..
For everything, use:
(defun close-clean (Reactor Info)
(vlr-remove-all)
)

I experimented onece and got an error message trying to remove :VLR-Miscellaneous-Reactor with (vlr-remove-all :VLR-Miscellaneous-Reactor) when there was no Miscellaneous Reactors active. I fear to did a mistake but it seems to me I did some repetition experiments and it was so again....Maybe (vlr-remove-all) will be more humane??? ; )
As to clearing out symbol names, it only matters when in SDI and LISPINIT is set to 0.

Thanks God! - it is very little possibly I think, but I can't be sure so I have to control this myself. Thank you!

Don't miss another important point about John's
post. Callback functions, even for cleaning up,
must have arguments in accordance with the
specifications in the lisp documentation.

Yes! I did so but I've simplified my example too much!
Unless writing a separate namespace application,
I prefer not to call (vlr-remove-all) or to use
the method John' used for cleaning up command
reactors because I believe each application should
be responsible for cleaning up after itself.
Agree.

I sometimes use (setq reactors (vlr-remove-all))
when I want to temporarily disable other reactors
and then add them back with (vlr-add reactors)
to re-enable them.

Very nice and simple! ; )
A cleanup reactor can also disable itself while it is
operating.

Glad to hear that, did so already, it's working!
 

Latest threads

Back
Top