[Prev][Next][Index][Thread]
each-subclass slot specializer working examples?
-
To: info-dylan@ai.mit.edu
-
Subject: each-subclass slot specializer working examples?
-
From: dauclair@hotmail.com
-
Date: Mon, 27 Mar 2000 23:30:02 -0500 (EST)
-
Organization: Deja.com - Before you buy.
-
Xref: traf.lcs.mit.edu comp.lang.dylan:11751
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: