define-behavior
is a special form for defining continuous
behaviors that are enabled and disabled by splats. Behaviors are
generally closed-loop control laws that do not have discrete action
semantics.
(name . args)
(name . args)
binding form operates like the
equivalent part of the define-splat
special form.
name is bound to a function of arguments args which
returns an object of type <splat-behavior>
. In order
to enable the behavior, the method (enable behavior)
must be called. To stop the behavior, use the method (disable
behavior)
.
The variables listed in the args list are in scope throughout
the body of the define-behavior
form, as is the variable
self
, which refers to the <splat-behavior>
object returned by the function bound to name
(local-vars (arg val) ...)
local-vars
form operates identically to the
define-behavior
form of the same name.
(enable . body)
enable
method
is called on the behavior. The thread running the control
function is guaranteed not to start until after the enable
function completes.
(disable . body)
disable
method
is called on the behavior. The control
function is
guaranteed not to run after the disable
function is called.
(control . body)
(check-for-disable self)
at each iteration. If the
disable
method has been called, check-for-disable
will not return and the thread controlling the behavior will be
terminated. The thunk defined in the disable
form will be
called immediately before the thread exits, after
check-for-disable
has been invoked. Local variables defined
in the local-vars
form keep their values.