unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* GOOPS with variable number of arguments
@ 2015-11-27 22:58 Jan Wedekind
  2015-11-27 23:30 ` David Kastrup
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Wedekind @ 2015-11-27 22:58 UTC (permalink / raw)
  To: guile-user

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.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-28 22:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-27 22:58 GOOPS with variable number of arguments Jan Wedekind
2015-11-27 23:30 ` David Kastrup
2015-11-28 22:24   ` Jan Wedekind

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).