[Prev][Next][Index][Thread]

each-subclass slot specializer working examples?



Another question: I'm having trouble getting the each-subclass slot
specializer working (it'd be even nicer if the slot in the subclasses
were constant).

So we have

// ---- code ----
define abstract class <face> (<object>)
  each-subclass slot value :: <integer>;
end class;

define class <jack> (<face>)
  inherited slot value = 1;
end class;

define class <ten> (<face>)
  inherited slot value = 10;
end class;

define class <seven> (<face>)
  inherited slot value = 0;
end class;

define method \+(a :: <face>, b :: <face>) => (c :: <integer>)
  a.value + b.value;
end;
// -- end-code --

So, when I try:

begin
  let a = make(<ten>);
  let b = make(<jack);
  let c = make(<seven>);
  values(a + b, b + c, c + a);
end;

I get an uninitialized slot error.  I've tried initializing the slots
after defining the classes and I've tried playing with the slot
specializers in the base and sub classes.

Any suggestions?

Sincerely,
Doug Auclair


Sent via Deja.com http://www.deja.com/
Before you buy.



Follow-Ups: