HaloO,

Jonathan Lang wrote:
 subset Rectangle of class {
   is Polygon;
   method width { ... }
   method height { ... }
   ...
 } where { [EMAIL PROTECTED] == 4 && ...}

?

Anonymous classes are useful things.

This is weird. The Polygon object shall be dynamically classified
as a Rectangle depending on the where clause. How does an object
that is an instance of the anonymous class get rid of its membership
when e.g. a fifth vertex is added? Or going the other way, how does
a general Polygon become an instance of the anonymous class when it
is modified such that it becomes a Rectangle? Remember that I've
used the Polygon/Rectangle example also to illustrate the question
how to retype an object.

The thing that the proposal shall achieve is to attach methods to
subset types. Multis can already be defined outside of class/role
implementations. So an alternative to the proposal to add a body
to the subset definition is to invent a syntax for outside methods.
I think it could look as follows:

  method width  on Rectangle {...}
  method height on Rectangle {...}

The on-part drops the method into the respective type.

Regards, TSa.
--

Reply via email to