Call an object method: Difference between revisions
Content added Content deleted
m (→With Closures: Minor docstring tweak) |
m (→With Lightweight Processes: Fixed docstrings) |
||
Line 458: | Line 458: | ||
(defun fish-class (species children) |
(defun fish-class (species children) |
||
" |
" |
||
This |
This constructor is useful for two reasons: |
||
1) as a way of abstracting out the id generation from the |
|||
generation from the larger constructor. Nothing else uses fish-class/2 |
|||
larger constructor, and |
|||
besides fish-class/1, so it's not strictly necessary. |
|||
2) spawning the "object loop" code (fish-class/3). |
|||
When the id isn't known, generate one. |
When the id isn't known, generate one. |
||
Line 475: | Line 476: | ||
" |
" |
||
This function is intended to be spawned as a separate process which is |
This function is intended to be spawned as a separate process which is |
||
used to track the state of a fish. |
used to track the state of a fish. In particular, fish-class/2 spawns |
||
this function (which acts as a loop, pattern matching for messages). |
|||
" |
" |
||
(let ((move-verb '"swam")) |
(let ((move-verb '"swam")) |