From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.devel Subject: Keyword args (was: Return) Date: Fri, 10 Dec 2010 09:53:06 +0100 Message-ID: References: <87mxojwu15.fsf@uwakimon.sk.tsukuba.ac.jp> <87k4jnweng.fsf@uwakimon.sk.tsukuba.ac.jp> <87d3pdwt1x.fsf@uwakimon.sk.tsukuba.ac.jp> <87bp4x37ey.fsf@lola.goethe.zz> <874oapwnon.fsf@uwakimon.sk.tsukuba.ac.jp> <4D01D9D8.5040400@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1291971296 32358 80.91.229.12 (10 Dec 2010 08:54:56 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 10 Dec 2010 08:54:56 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 10 09:54:52 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQyke-0007Ub-8a for ged-emacs-devel@m.gmane.org; Fri, 10 Dec 2010 09:54:52 +0100 Original-Received: from localhost ([127.0.0.1]:45338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQykd-0003PS-T9 for ged-emacs-devel@m.gmane.org; Fri, 10 Dec 2010 03:54:51 -0500 Original-Received: from [140.186.70.92] (port=46733 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQyjF-0002bN-Jy for emacs-devel@gnu.org; Fri, 10 Dec 2010 03:53:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PQyjD-0004dH-Gf for emacs-devel@gnu.org; Fri, 10 Dec 2010 03:53:25 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:49745) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PQyjD-0004bB-6T for emacs-devel@gnu.org; Fri, 10 Dec 2010 03:53:23 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PQyjA-0006u1-CV for emacs-devel@gnu.org; Fri, 10 Dec 2010 09:53:20 +0100 Original-Received: from 212.46.169.137 ([212.46.169.137]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 10 Dec 2010 09:53:20 +0100 Original-Received: from eller.helmut by 212.46.169.137 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 10 Dec 2010 09:53:20 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 65 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 212.46.169.137 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:naWNVrXGcOHJ0XpkrNI1S3tGGXM= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:133568 Archived-At: * Daniel Colascione [2010-12-10 07:42] writes: > On 12/7/10 8:30 AM, Stephen J. Turnbull wrote: >> David Kastrup writes: >> >> > I don't think anybody minds the features. >> >> IIRC rms has recently declared his dislike for CL-style keyword >> arguments. I suppose that's part of the "syntactic complexity" you >> mention, but MON KEY OTOH points out cases where he'd like to use >> them. So there are some fundamental disagreements here. > > I'd just like to add my support for keyword arguments. Functions like > write-region are both horrible and brittle because their parameters are > both numerous and overloaded; specific functionality can be more simply > expressed with using keyword arguments. You always have the option to make a macro with keyword arguments which expands to a call to the "raw" function. The only disadvantage of this approach is that macros can't be used with higher order functions, ala mapcar. But keyword arguments a rarely useful in that case. > Precedent can be seen in play-sound, defcustom, and elsewhere. For a bad example see make-network-process. That takes keyword arguments but the keyword parsing is done in C and it doesn't do a good job. It doesn't detect invalid keywords; doesn't detect conflicting keys; some keys are documented to be ignored when some other keys are supplied. It's very difficult to use. Correct keyword parsing in C is difficult so I would vote against it. Also note that defcustom is a macro and play-sound takes a plist. The plist idiom is IMO superior to keywords. In particular passing arguments along gets easier. E.g. (defun foo (x y plist) (bar x y) (baz plist)) is IMO more readable than: (defun* foo (x y &key key1 key2 key3) (bar x y) (baz :key1 key1 :key2 key2 :key3 key3)) or the rather silly (defun* foo (x y &rest plist &key key1 key2 key3) (bar x y) (apply #'baz plist)) Since we have destructuring-bind parsing plists is not very hard. > The performance arguments opposing > keyword arguments don't seem to be supported by benchmarks, and in any > case, most functions, especially ones with rich functionality, aren't on > the fast path. The sequence functions find, position, assoc*, member* etc. are on the fast path. Ironically those are the functions where keyword args are very useful because the meaning is relatively consistent. Helmut