|
From: | John Lenz |
Subject: | [Chicken-users] tinyclos and variable argument functions |
Date: | Sat, 02 Apr 2005 22:42:00 +0000 |
(require 'tinyclos) (define-method (foo (a <top>) (b <top>)) (print "two")) (define-method (foo (a <top>)) (print "one")) (foo 3) -> prints "one" (foo 1 2) Error: bad argument count - received 3 but expected 2If I reverse the way foo is defined, by defining the one before the two, then the (foo 3) will give a bad argument count. I use <top> in this example, but it is the same for other classes as well.
Is this just a limitation of tinyclos or is it a bug in tinyclos? If it is a limitation, what do you think is the best way to get around it? Write a macro that looks similar to define-method, but creates a new generic for each argument length and stores them all in a vector? Then return a function that first checks the argument length and looks up the right generic to apply?
John
[Prev in Thread] | Current Thread | [Next in Thread] |