chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] coops / override initialize-instance


From: Felix
Subject: Re: [Chicken-users] coops / override initialize-instance
Date: Wed, 09 Mar 2011 06:59:00 -0500 (EST)

From: John J Foerch <address@hidden>
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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]