21
inter/db/21 · 1.0 KB
From the archive interlude_1beta5.tar.gz
Download the archive « Back to the archive contents
14
name
"coordinate type"
/
instantiate
(method (xcoord ycoord)
(class this (tolist xcoord ycoord)))
/
distance
;; this allows you to do things like (call {#21 '(1 2)} distance {#21 '(9 4)})
;; ... it looks more elegant when the values are saved to symbols, since you
;; can then say (coordinate:distance other-coordinate)
(method (this-val to-coord)
(if (and (= (typeof (typeof to-coord)) 'OBJECT)
(= (typeof to-coord) this))
(to-coord:distance-private (index 1 this-val) (index 2 this-val))
(raise E_PERM
"Invalid attempt to find distance to non-coordinate value")))
/
distance-private
;; this is the private implementation of 'distance' ... the end-user should
;; never call it.
(method (this-val to-x to-y)
(if (= caller this)
(square-root (+ (square (- to-x (index 1 this-val)))
(square (- to-y (index 2 this-val)))))
(raise E_PERM "distance-private is a private method to this object")))
/
/
/+++++++++++++++++++++++ end of object 21 ++++++++++++++++++++++++++++++++