An Example of an Object: Dynamic Plotting



next up previous
Next: Some Matrix Examples Up: A Few Simple Previous: A History Mechanism

An Example of an Object: Dynamic Plotting

Lisp-Stat has a special data type known as an object. Lisp-Stat objects are similar to structures in C, except that in addition to holding data in slots, they can also respond to certain messages. The function send is used to send messages to objects.

First let's make an object.

> (def myplot (histogram (normal-rand 100)))
MYPLOT

How do we know this is an object? Lisp-Stat has a predicate function objectp which tells us:

> (objectp myplot)
T
In other words, the answer to the question: ``Is myplot an object?'' is ``true''.

The simplest message to send to our object is :help.

> (send myplot :help)
ABLINE ACTIVATE ADD-FUNCTION ADD-LINES ADD-METHOD ADD-MOUSE-MODE 
ADD-POINTS ADD-SLOT ADJUST-POINTS-IN-RECT ...
and much, more.
> (send myplot :help :add-points)
ADD-POINTS
Method args: (points (draw t))
Adds points to plot. POINTS is a sequence or a list of sequences. 
If DRAW is true the new points are added to the screen.
Thus we can add some points points to our histogram without recalculating it from scratch:
> (send myplot :add-points (normal-rand 100))
results in a histogram for 200 points.




Tue Aug 29 09:10:30 MDT 1995