[plt-scheme] Organizing Code, Pt.2

From: Kevin A. Smith (kevin at hypotheticalabs.com)
Date: Tue Mar 14 06:09:16 EST 2006

Danny Yoo wrote:

>>(module module-a
>>   (lib "swindle.ss" "swindle")
>>
>>   (defclass test-parent()
>>      (name :accessor name :initarg :name))
>>
>>   (provide test-parent))
>>
>>Requiring this module allows me to create instances of the class but
>>inspecting these instances fail:
>>
>>=> (require (lib "swindle.ss" "swindle"))
>>=> (require "module-a.scm")
>>=> (define tp (make test-parent :name "Parent"))
>>=> (display-object tp)
>>#<test-parent:Parent>=> (name tp)
>>reference to undefined identifier: name
>>    
>>
>
>
>Hi Kevin,
>
>I'm not too familiar with CLOS yet, but does SLOT-REF do what you want?
>
>;;;;;;
>  
>
>>(slot-ref (make test-parent :name "Parent") 'name)
>>    
>>
>"Parent"
>;;;;;;
>
>
>Best of wishes!
>
>  
>
Yep. slot-ref seems to work, so that's a possibility. I'm still curious 
as to why (name tp) fails. I think I'm missing something about how 
Swindle generates accessors because mzscheme complains about duplicate 
identifier definitions when I add:

(define (name tp)
   (slot-ref tp 'name))

--Kevin


Posted on the users mailing list.