[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] coops
From: |
schugk |
Subject: |
Re: [Chicken-users] coops |
Date: |
Wed, 19 Jan 2011 03:09:22 +0100 |
User-agent: |
Internet Messaging Program (IMP) H3 (4.1.6) |
The version you install is 1.1
Then a new version does not solve my problem. Here is some code:
(define-generic (show s))
(define-method (show (s <number>))
(number->string s))
(define-method (show (s <symbol>))
(symbol->string s))
(define-method (show (s <pair>))
(string-append "(" (show (car s)) "," (show (cdr s)) ")"))
(define-method (show (s <list>))
(apply string-append (map show s)))
I expected that (show '(1 2 3 4)) is evaluated to "123". But the
specialized method for <list> is only called if the value of s is
<null>. Instead the method for <pair> is called and is evaluated to
"(1,(2,(3,(4,(5,)))))". My problem is that <pair> is always preferred
because <pair> is a subclass of <list>. If i change some lines in
coops-primitive-objects.scm so that <list> is a subclass of <pair>
everything works fine.
Is there a reason why <pair> is a subclass of <list>?
Thanks,
Sandro
coops-primitive-objects.scm changed to
48: (defprim <pair> pair? <sequence>)
49: (defprim <list> list? <pair>)
50: (defprim <null> null? <immediate> <list>)
- [Chicken-users] coops, schugk, 2011/01/16
- Re: [Chicken-users] coops, Felix, 2011/01/17
- Re: [Chicken-users] coops,
schugk <=
- Re: [Chicken-users] coops, Christian Kellermann, 2011/01/19
- Re: [Chicken-users] coops, schugk, 2011/01/19
- Re: [Chicken-users] coops, Thomas Chust, 2011/01/19
- Re: [Chicken-users] coops, schugk, 2011/01/19
- Re: [Chicken-users] coops, Christian Kellermann, 2011/01/19
- Re: [Chicken-users] coops, Felix, 2011/01/20
- Re: [Chicken-users] coops, John Cowan, 2011/01/20
- Re: [Chicken-users] coops, Thomas Chust, 2011/01/19
- Re: [Chicken-users] coops, Felix, 2011/01/25