guile-user
[Top][All Lists]
Advanced

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

Re: GOOPS with variable number of arguments


From: Jan Wedekind
Subject: Re: GOOPS with variable number of arguments
Date: Sat, 28 Nov 2015 22:24:01 +0000 (GMT)
User-agent: Alpine 2.11 (DEB 23 2013-08-11)

Ok, thanks. I'll use that solution.

On Sat, 28 Nov 2015, David Kastrup wrote:

Jan Wedekind <address@hidden> 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

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