Kent M Pitman <email@example.com> wrote:
| We could get read of 0d arrays, similarly; many people find
| (aref foo) and (setf (aref foo) 1) to be very bizarre to look at.
Actually, I pointed to those once when somebody said, "But MzScheme
...records with a single mutable field:
(box v) returns a new box that contains v.
(unbox box) returns the content of box.
For any v, (unbox (box v)) returns v.
(set-box! box v) sets the content of box to v.
(box? v) returns #t if v is a box, #f otherwise.
My retort, "Well, so does CL, so there!" ;-}
(defun box (v)
(make-array nil :initial-element v))
(defun unbox (box)
(defun set-box! (box v)
(setf (aref box) v))
(defun box? (v)
(and (arrayp v) (zerop (array-rank v))))
[Of course, I really should have used just the car of a cons, but he
was under the odd impression that boxes simply *had* to be smaller
than pairs, so I used something else. ;-} ]
But it *is* amusing the first time you see how the above-defined
"boxes" print. [Try (box 123.45) or (box :hello), etc.] Perfectly
reasonable, in retrospect, once one gets over the startlement.
Rob Warnock, PP-ASEL-IA <firstname.lastname@example.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607