Subject: Re: (upgraded-array-element-type nil)
From: rpw3@rpw3.org (Rob Warnock)
Date: Sun, 02 Feb 2003 05:59:27 -0600
Newsgroups: comp.lang.lisp
Message-ID: <A1GdnYhwW-2ClaCjXTWc-w@speakeasy.net>
Kent M Pitman  <pitman@world.std.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
has boxes!"

	...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)
	  (aref 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

-----
Rob Warnock, PP-ASEL-IA		<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607