From: Jan Wedekind <jan@wedesoft.de>
To: David Kastrup <dak@gnu.org>
Cc: guile-user@gnu.org
Subject: Re: GOOPS with variable number of arguments
Date: Sat, 28 Nov 2015 22:24:01 +0000 (GMT) [thread overview]
Message-ID: <alpine.DEB.2.11.1511282218300.7500@wedemob> (raw)
In-Reply-To: <87r3jbxbp7.fsf@fencepost.gnu.org>
Ok, thanks. I'll use that solution.
On Sat, 28 Nov 2015, David Kastrup wrote:
> Jan Wedekind <jan@wedesoft.de> 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.
>
>
prev parent reply other threads:[~2015-11-28 22:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.11.1511282218300.7500@wedemob \
--to=jan@wedesoft.de \
--cc=dak@gnu.org \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).