[plt-scheme] class.ss's init, and non-public fields

From: ian barland (will wake for food) (ian at cs.rice.edu)
Date: Thu Feb 17 10:23:38 EST 2005

>> Is there a way to specify a set of fields that a class must implement
>> using the PLT object system (i.e. class.ss)?
>> 
> Come to a neighborhood near you real soon, or so they say. But don't 
> hold your breath.
> 
>> If not how do you do this - define a superclass that contains the
>> required fields and derive a new class from it?
>> 
> Yes.

 
A different question, also about class.ss.  From the docs:
]
] Only initialization variables declared with init-field can be accessed 
] from methods; accessing any other initialization variable from a method 
] is a syntax error. 
] 
(1a) Why this restriction?
(1b) Is there a workaround better than
  ...
  (init size)
  (define _init init) ; use _init inside my own methods
  ...

(2) class.ss doesn't have abstract classes.  After some thought, I
realize it's because it's an unnecessary concept?
('Abstract class' just means a class that doesn't fully meet the interface
you want yet; instead use an interface to describe the type, and 
an ordinary class Abstr% (not meeting the interface) to hold any shared code,
and then extend Abstr% with classes that *do* meet the interface.)
(2a) Is there anything subtle which abstract classes provide, and
     this approach doesn't?
(2b) Hmm, a short "class.ss for java programmers" might be a useful page
     for students.  I'll get to this eventually myself, but it won't
     be 'til the end of the semester at least...

Thanks,
ian



Posted on the users mailing list.