[plt-scheme] instantiating another instance of same class

From: Neil W. Van Dyke (neil at neilvandyke.org)
Date: Wed Apr 9 09:51:33 EDT 2003

OK, thanks; I can use a factory in this case, and a factory does have
one potential abstraction benefit in this case (although it makes
subclass extension more cumbersome).

I am curious as to the rationale for not being able to ask the class of
object.  I realize you guys have knowingly avoided Smalltalk-like
metaclasses, but the `class*' and `instantiate' syntax suggest that
classes are first-class [pun] values, and one can test an instance
against a given class predicate.  This is a significant theoretical
distinction, but I'm curious as to whether there's a significant
performance or flexibility win.

Robby Findler <robby at cs.uchicago.edu> writes at 08:28 09-Apr-2003 -0500:
> You can use design patterns to do this (eg for 3. use factory method)
> and you could even build macros on top of the class system that build
> this kind of thing in, using the design patterns. I don't believe that
> there is any native support for it, however.
> Robby
> At Wed, 9 Apr 2003 08:55:52 -0400, "Neil W. Van Dyke" wrote:
> >   For list-related administrative tasks:
> >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> > 
> > Is there a way to do any of the following with the object system
> > (in decreasing order of generality)?
> > 
> >   1. Procedure that accepts an object instance and returns the object
> >      class.
> > 
> >   2. Way to get the most specific class of an instance from within a
> >      method of the instance.
> > 
> >   3. Way from within a method to make a new instance of the instance's
> >      class, with specified init fields.
> > 
> > -- 
> >                                              http://www.neilvandyke.org/

Posted on the users mailing list.