[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Re: coops / override initialize-instance
From: |
John J Foerch |
Subject: |
[Chicken-users] Re: coops / override initialize-instance |
Date: |
Wed, 09 Mar 2011 14:22:33 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
Felix <address@hidden> writes:
> 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
elegant; thank you very much.
--
John Foerch