anchor.diff:      :type fixnum
       :documentation "When this event must be executed.")
   
  -   (!action
  -    :initarg :!action
  +   (action
  +    :initarg :action
       :initform (error "missing :action")
  -    :reader !action-of
  +    :reader action-of
       :type function   ; FIXME: must fully specify signature.
       :documentation "Implements the behaviour of this event, taking the
       world as its only argument and modifying it.
  
positive.code: (defpackage :org.altervista.rjack.desim
    (:nicknames :ds)
    (:use :common-lisp)
    (:export :!transform :clone :run :next :prev
  	   :identifiable :id-of
  	   :simulated :description-of
  	   :event :time-of :!action-of
  	   :world :hystory-of :events-of))
  
  
  (in-package :ds)
  
  
  (defgeneric !transform (dest source)
    (:documentation "Fill dest with some, all or none of the values from
    source."))
  
  
  (defgeneric clone (object)
    (:documentation "Return a shallow copy of object."))
  
  
  (defgeneric run (world event)
    (:documentation "Execute the action associated with event returning
    a new world, possibly different from the given one."))
  
  
  (defgeneric next (world)
    (:documentation "Return the next world, based on the given one."))
  
  
  (defgeneric prev (world)
    (:documentation "Return the previous world, relative to the given
    one."))
  
  
  (defclass identifiable ()
  
negative.code:     :documentation "World's events.")))
  
  
  (defmethod schedule ((w world) (ev event))
    (assert (>= (time-of ev) (clock-of w)) nil
  	  "Scheduling an event in the past.")
    (setf (events-of w)
  	(sort (cons ev (events-of w))
  	      #'< :key #'time-of)))
  
  
  (defmethod next ((w world))
    (with-accessors ((events events-of) (clock clock-of)) w
      (when (not (null events))
        (let ((ev (pop events)))
  	(setf clock (time-of ev))
  	(format t "~&~D " clock)
  	(funcall (action-of ev) w)
  	w))))
  