[plt-scheme] constructor in class.ss?

From: Jon Rafkind (workmin at ccs.neu.edu)
Date: Sat Oct 22 21:53:36 EDT 2005

Im using the class system imported from class.ss and cant figure out how 
to invoke a constructor of some sort on the object Im instantiating. 
Actually my real problem is I want to initialize a field and add it to a 
list at the same time. Something like

(define foo%
   (class* object% ()
      (init-field (bar #f))
      (define bars '())))

(define f-instance (new foo% (bar 'tomato)))

Should set f-instance's bar field to 'tomato and I want to add 
f-instance's bar to f-instance's `bars' list. The reason for this is the 
bar I am initializing f-instance with is special and I will add more 
bar's to the bars list later on.

Ive been reading the docs on class.ss but cant figure out if there is 
some way to manipulate the class in an arbitrary way upon instantiation 
or if I have to resort to tricks( such as using a box or something ). 
Maybe Im just blind.

thanks,
jon


Posted on the users mailing list.