guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GOOPS with variable number of arguments


From: Jan Wedekind
Subject: GOOPS with variable number of arguments
Date: Fri, 27 Nov 2015 22:58:36 +0000 (GMT)
User-agent: Alpine 2.11 (DEB 23 2013-08-11)

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

[Prev in Thread] Current Thread [Next in Thread]