From: John J Foerch <[email protected]>
Subject: [Chicken-users] coops / override initialize-instance
Date: Tue, 08 Mar 2011 16:30:32 -0500

> Hello,
> 
> What is the recommended way to perform complex initialization of object
> instances in coops?  Say I need to initialize a certain slot based on
> the values of other slots in the object.  Is the initialize-instance
> generic designed in a way that it is safe to do something like this:
> 
>   (define-method (initialize-instance (o <myobject))
>     ;; initialization code here
>     )
> 
> or is it recommended to write a wrapper function like this:
> 
>   (define (make-myobject a b c)
>     (let ((o (make <myobject> 'a a 'b b 'c c)))
>       ;; initialization code here
>       o))

"initialize-instance" is the right way to do it. You just should make
sure to use "call-next-method" before you you can refer to other
slots, because the default method initializes all slots with their
default values.


cheers,
felix

_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to