Subject: Re: YA Scheme critique
From: (Rob Warnock)
Date: 14 Jun 2002 08:34:43 GMT
Newsgroups: comp.lang.scheme
Message-ID: <aec9r3$11qsl$>
felix <> wrote:
| >> [CL] "adjustable arrays", and the links to MAKE-ARRAY and ADJUST-ARRAY.
| >
| >Quite right.  Ironically, so does Smalltalk,[...]
| Smalltalk has `become:', which is orders of magnitude more powerful
| and general than fill-pointers...

Indeed. Similarly, Common Lisp provides dynamic redefinition of
classes, wherein all existing instances of the class get automatically
converted to the new class definition (which can be customized
(dynamically change the class of a specific instance, which can

These changes can cause slots to be added or deleted, or be completely
redefined while the program is running. E.g., there's an example at
f_upda_1.htm> of defining a class "X-Y-POSITION" in rectangular
coordinates, running the program for a while (instantiating a number
of instances), then noticing that:

    ;;; It turns out polar coordinates are used more than Cartesian 
    ;;; coordinates, so the representation is altered and some new
    ;;; accessor methods are added.

By defining a method for UPDATE-INSTANCE-FOR-REDEFINED-CLASS which
is specialized for class X-Y-POSITION before the redefinition, the
existing instances can be automatically converted from rectangular
coordinates to polar.

Two points (pardon the pun!) that may be of interest from "4.3.6
Redefining Classes" <URL:

    When the class C is redefined, changes are propagated to its
    instances and to instances of any of its subclasses. Updating
    such an instance occurs at an implementation-dependent time,
    but no later than the next time a slot of that instance is
    read or written.

That is, the implementation is permitted to call UPDATE-INSTANCE-FOR-
REDEFINED-CLASS on instances lazily, as needed, thus spreading out
the computational load of the conversion (or deferring it altogether
for instances that are never accessed after the redefinition). And:

    Updating an instance does not change its identity as defined by
    the function EQ. The updating process may change the slots of
    that particular instance, but it does not create a new instance.

This almost (but not quite) mandates a level of indirection between
an "instance" and the internal storage for the instance. [I say "not
quite" because that indirection need not occur for classes which are
never redefined... though I don't know if any existing implementations
actually make use of that flexibility.]


Rob Warnock, 30-3-510		<>
SGI Network Engineering		<>
1600 Amphitheatre Pkwy.		Phone: 650-933-1673
Mountain View, CA  94043	PP-ASEL-IA

[Note: and aren't for humans ]