Ok, thanks. I'll use that solution.

On Sat, 28 Nov 2015, David Kastrup wrote:

Jan Wedekind <[email protected]> writes:

Hi,
I am trying to implement n-ary operations for different types of objects.
When specialising "+" for two arguments, it will automatically work on
more arguments.

    (use-modules (oop goops) (srfi srfi-1))
    (define-generic +)
    (define-method (+ (a <string>) (b <string>)) (string-append a b))
    (+ "a" "b" "c")
    ; "abc"

However I have trouble figuring out a method definition for test which
would result in the same behaviour.

    (define (test . args) ...)
    (define-generic test)
    (define-method (test (a <string>) (b <string>)) (string-append a b))
    (test "a" "b" "c")
    ; "abc"

Please let me know if there is a solution.



Reply via email to