[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] tinyclos and variable argument functions
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] tinyclos and variable argument functions |
Date: |
Wed, 6 Apr 2005 08:47:57 +0200 |
>
> I also think there might be a problem with define-macro... With the above
> patch to tinyclos,
> the following code gives somewhat strange results:
>
> #;2> (define-method (foo (a <top>) b) (print "two " a " " b))
> #;3> (define-method (foo (a <top>)) (print "one " a))
> #;4> (foo 3 2)
> Error: bad argument count - received 3 but expected 2
> #;4> (foo 3)
> one 3
> "one "
> #;5> (define-method (foo (a <top>) (b <top>)) (print "two other " a " " b))
> #;6> (foo 3 2)
> two other 3 2
> "two other "
>
> What is going on here is that when expanding the first define-method,
> define-method is
> passing the list of specializers to (add-global-method) as '(<top>). This is
> because
> of lines 482 in chicken-highlevel-macros.scm:
> (if (or (not (pair? args))
> (and (not (pair? (car args)))
> (not (scan (cdr args))) ) )
> Since define-method stops generating the list of specializers when it finds
> no more
> pairs left in the list of arguments, b's type (which is <top>) is never
> getting added
> to the list. It makes for a wierd case where wrapping b inside a (b <top>)
> works
> whereas it doesn't if b is just left open.
>
> Thus, during add-method, since the list of specializers for the first method
> is equal
> to the list for the second, the second define-method is replacing the first.
>
But is this so weird? A non-specialized argument ("b" in the first
define-method) must be an instance of something in the end...
cheers,
felix