From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.user Subject: Do we have to worry about the names of generic functions? Date: Wed, 12 May 2004 11:34:08 +0100 Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <1084358048.15175.235.camel@localhost> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1084378106 784 80.91.224.253 (12 May 2004 16:08:26 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 12 May 2004 16:08:26 +0000 (UTC) Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed May 12 18:08:07 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 1BNwH9-0006wj-00 for ; Wed, 12 May 2004 18:08:07 +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 1BNw8c-0006qo-Dr for guile-user@m.gmane.org; Wed, 12 May 2004 11:59:18 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BNrhW-00046q-BU for guile-user@gnu.org; Wed, 12 May 2004 07:15:02 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BNrLj-0001nd-1L for guile-user@gnu.org; Wed, 12 May 2004 06:53:03 -0400 Original-Received: from [216.166.232.203] (helo=johnson-resources.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1BNrDW-0000p2-RO for guile-user@gnu.org; Wed, 12 May 2004 06:44:03 -0400 Original-Received: from localhost (mantis.schoolnet.na [::ffff:196.44.140.238]) (AUTH: LOGIN wingo) by johnson-resources.com with esmtp; Wed, 12 May 2004 06:38:57 -0400 Original-Received: from wingo by localhost with local (Exim 3.36 #1 (Debian)) id 1BNr3x-0002Ho-00 for ; Wed, 12 May 2004 11:34:09 +0100 Original-To: Guile Users X-Mailer: Ximian Evolution 1.4.4 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:3163 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:3163 Hi, 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've been trying to think of reasons for worry, and arguments against the reasons, if I can find them. They're discussed below. Feel free to add any that I missed, or correct anything that's unfair. * Generics clobber the namespace. I was inclined to believe this, but now I'm not so sure. Consider a generic, `output'. I assert that x.output() in Python does not clobber the namespace. x.output is syntactic sugar for referencing the output field of x, and () means to invoke the returned object. If output is a bound method, that means it will be invoked as output(x) -- exactly the same as (output x) in guile. The only difference regards field lookup, which can be viewed as a limited version of multi-method dispatch. Although the name `output' is available to the world, the fact that it is specialized restricts its validity to a certain subset of objects. This subset is similar to python's "set of objects that have a field named `output'". 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? * Dispatching a generic with many methods might be inefficient. If this is a problem, it should be solved in GOOPS. * 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. * It's not obvious, when you read code, that you're calling a generic. Hm. Well the short names of most of them is a clue ;) But seriously, I don't know what to do here. JScheme has java-dot notation, where calling java methods is done like (.uglyMethodName x), which is ugly but more obvious. Some naming convention would be good here, I think... * Conclusion So, I haven't yet decided about naming generics. 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. -- Andy Wingo _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user