From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Rob Browning Newsgroups: gmane.lisp.guile.user Subject: Re: Do we have to worry about the names of generic functions? Date: Thu, 13 May 2004 13:38:47 -0500 Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <87isf0qiiw.fsf@trouble.defaultvalue.org> References: <1084358048.15175.235.camel@localhost> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1084473820 20107 80.91.224.253 (13 May 2004 18:43:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 13 May 2004 18:43:40 +0000 (UTC) Cc: Guile Users Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu May 13 20:43:33 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BOLB6-00062k-00 for ; Thu, 13 May 2004 20:43:32 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BOL8y-0003qO-Cb for guile-user@m.gmane.org; Thu, 13 May 2004 14:41:20 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BOL8k-0003pB-5P for guile-user@gnu.org; Thu, 13 May 2004 14:41:06 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BOL8E-0003du-2z for guile-user@gnu.org; Thu, 13 May 2004 14:41:05 -0400 Original-Received: from [66.93.216.237] (helo=defaultvalue.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BOL80-0003bf-QN for guile-user@gnu.org; Thu, 13 May 2004 14:40:21 -0400 Original-Received: from trouble.defaultvalue.org (omen.defaultvalue.org [192.168.1.1]) by defaultvalue.org (Postfix) with ESMTP id 519854094; Thu, 13 May 2004 13:40:20 -0500 (CDT) Original-Received: by trouble.defaultvalue.org (Postfix, from userid 1000) id 92261410C7; Thu, 13 May 2004 13:38:47 -0500 (CDT) Original-To: Andy Wingo In-Reply-To: <1084358048.15175.235.camel@localhost> (Andy Wingo's message of "Wed, 12 May 2004 11:34:08 +0100") User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:3170 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:3170 Andy Wingo writes: > I have a question for people, the answer to which will hopefully lay to > rest a lot of namespace-related debate. That question is, do we have to > worry about the names of our generic functions? I just asked basically the same question on guile-devel, not realizing you'd already done so here :> > * Generics clobber the namespace. > To put it another way: what's the difference between (output x) and the > more smalltalk-like (x 'output)? The argument above leads to the > conclusion that there is no difference, and therefore that generics do > not clobber namespaces. > > Is there a hole in that argument? One thing to consider is that at least in CLOS (and I'd presume GOOPS, though I'm not as familiar with it), there are more sophisticated multiple argument dispatch and multiple inheritance issues that may distinguish the C++/python-esque "x.foo()" from CLOS/GOOPS "(foo x)", or perhaps more accurately they may distinguish something like "x.foo(a, b)" from "(foo x a b)". With (foo x a b), x is not nearly as "privileged" as it is in x.foo(a, b) because instead of just considering the type of x, you have to consider the types of all of the arguments, x, a, and b, and each one's class hierarchy, when trying to determine dispatch. Of course C++ has operator overloading and implicit coercions which also complicate reading a call, and require knowledge of more than just the type of x to determine what's going on. > * Using generics might be less readable. > > This is indeed a problem. It can be solved by making generic names more > descriptive, or more commonly to make variable names more descriptive. > After all, x.output() doesn't tell you much, either. Yes, though choosing more distinguishing function names does have the advantage that you can easily do things like fgrep '(gtk-close' *.scm which wouldn't be possible if you're using the more generic names with disambiguating variable names: (close window-foo) ... (close window-bar) unless you use the same variable names in every invocation, or stick to a very regular variable naming pattern. Perhaps that's not a big deal, but it might be worth consideration. > So, I haven't yet decided about naming generics. And contrary to any impression I may have given above, I haven't either. Although it is true that I don't mind more specific names, and I have usually tended to think of generics more in terms of the functionality they can provide within a given set of related classes, I can also understand other people's desire to use the more generic names, even if it doesn't weigh as heavily with me. In any case, right now, I'd just like to try to make sure I understand the relevant issues, and I want to be cautious where public exports are concerned. > The debate comes up in the context of g-wrap, a FFI-generating > library. It exports some generic functions as part of its API, and > it's odd to see a library export symbols like `visible?' and > `add-item!'. All input on this issue is appreciated. Indeed. -- Rob Browning rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu GPG starting 2002-11-03 = 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4 _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user