From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Mikael Djurfeldt Newsgroups: gmane.lisp.guile.devel Subject: Re: primitive-generics are limited in their arities Date: Mon, 14 Jul 2003 18:03:15 +0200 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: References: <20030712102552.GA4329@lark> Reply-To: djurfeldt@nada.kth.se NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1058199327 17852 80.91.224.249 (14 Jul 2003 16:15:27 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 14 Jul 2003 16:15:27 +0000 (UTC) Cc: djurfeldt@nada.kth.se Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Jul 14 18:15:23 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19c5z1-0004dT-00 for ; Mon, 14 Jul 2003 18:15:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19c5yL-0000wa-PV for guile-devel@m.gmane.org; Mon, 14 Jul 2003 12:14:41 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19c5pb-0005KN-Af for guile-devel@gnu.org; Mon, 14 Jul 2003 12:05:39 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19c5p0-0004sz-E5 for guile-devel@gnu.org; Mon, 14 Jul 2003 12:05:03 -0400 Original-Received: from kvast.blakulla.net ([213.212.20.77]) by monty-python.gnu.org with esmtp (Exim 4.20) id 19c5nM-00040j-IH for guile-devel@gnu.org; Mon, 14 Jul 2003 12:03:20 -0400 Original-Received: from h45n1fls34o867.telia.com ([213.65.223.45] helo=witch) by kvast.blakulla.net with esmtp (Exim 3.36 #1 (Debian)) id 19c5nJ-0006Q3-00; Mon, 14 Jul 2003 18:03:17 +0200 Original-Received: from mdj by witch with local (Exim 3.35 #1 (Debian)) id 19c5nH-0000cG-00; Mon, 14 Jul 2003 18:03:15 +0200 Original-To: guile-devel@gnu.org In-Reply-To: <20030712102552.GA4329@lark> (Andy Wingo's message of "Sat, 12 Jul 2003 11:25:52 +0100") User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2625 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2625 Andy Wingo writes: > Hey goops hackers, > > I've run into an irritating little bug in primitive-generics where they > are limited to a specific arity. Here's a little example. > > guile> (use-modules (oop goops)) > guile> (define-method (write (foo ) (bar ) (baz )) > ... (display (list foo bar baz))(newline)) > guile> (write '(4 5 6) '(6 7) '(5 6)) > > Backtrace: > In current input: > 4: 0* [write (4 5 6) (6 7) (5 6)] > > :4:1: In procedure write in expression (write (quote #) > (quote #) ...): > :4:1: Wrong number of arguments to # write> > ABORT: (wrong-number-of-args) > guile> write > $1 = # > guile> (primitive-generic-generic write) > $2 = #< write (7)> > guile> ($2 '(4 5 6) '(6 7) '(5 6)) > ((4 5 6) (6 7) (5 6)) > > I wonder if this is a problem with the primitive-generic support or if > there's something that I'm doing wrong. It seems unnatural to have to > > (define-method write ...) > > and then > > (set! write (primitive-generic-generic write)) > > I tried to look into a fix but I got lost. What's the word on this? The arity of primitive generics is restricted to the arity of their primitive methods. Thus, if you want to have a different arity, you need to create a new generic function. In order to preserve the behavior, you can add the original functions as the default method: (define old-write write) (define write (make #:name 'write #:default old-write)) (define-method (write (foo ) (bar ) (baz )) (display (list foo bar baz)) (newline)) M _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel