all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Helmut Eller <eller.helmut@gmail.com>
To: emacs-devel@gnu.org
Subject: Keyword args (was: Return)
Date: Fri, 10 Dec 2010 09:53:06 +0100	[thread overview]
Message-ID: <m27hfi1025.fsf_-_@gmail.com> (raw)
In-Reply-To: 4D01D9D8.5040400@gmail.com

* 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




  reply	other threads:[~2010-12-10  8:53 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-05 23:55 Return MON KEY
2010-12-06  1:48 ` Return Stephen J. Turnbull
2010-12-06  5:50   ` Return MON KEY
2010-12-06  7:20     ` Return Stephen J. Turnbull
2010-12-06  9:00       ` Return David Kastrup
2010-12-06 19:11         ` Return Stefan Monnier
2010-12-06 19:09       ` Return Stefan Monnier
2010-12-06 19:19         ` Return Chong Yidong
2010-12-06 20:27           ` Return Stefan Monnier
2010-12-07  4:47         ` Return Miles Bader
2010-12-07  9:17           ` Return David Kastrup
2010-12-07 17:10             ` Return Stefan Monnier
2010-12-07 22:15               ` Return David Kastrup
2010-12-08 15:50             ` Return Fren Zeee
2010-12-09 22:38             ` Return Stefan Monnier
2010-12-10  1:41               ` Return Stephen J. Turnbull
2010-12-10  3:44                 ` Return Stefan Monnier
2010-12-10  8:28                   ` Return Stephen J. Turnbull
2010-12-23  5:39                     ` Return Fren Zeee
2010-12-07 12:44         ` Return Stephen J. Turnbull
2010-12-07 14:38           ` Return David Kastrup
2010-12-07 16:14             ` Return Stephen J. Turnbull
2010-12-07 17:11               ` Return tomas
2010-12-07  2:42       ` Return MON KEY
2010-12-07 14:34         ` Return Stephen J. Turnbull
2010-12-07 15:54           ` Return David Kastrup
2010-12-07 16:30             ` Return Stephen J. Turnbull
2010-12-08 13:42               ` Return Richard Stallman
2010-12-10  7:42               ` Return Daniel Colascione
2010-12-10  8:53                 ` Helmut Eller [this message]
2010-12-13  2:10                   ` Keyword args Daniel Colascione
2010-12-13  8:30                     ` Helmut Eller
2010-12-13 20:00                     ` Andy Wingo
2010-12-14  5:03                       ` Miles Bader
2010-12-14  7:43                         ` Helmut Eller
2010-12-07 22:55           ` Return MON KEY
2010-12-08  7:28             ` Return Stephen J. Turnbull
2010-12-08 18:11               ` Return MON KEY
2010-12-09  8:37                 ` Return Stephen J. Turnbull
2010-12-07 23:21         ` Return Samuel Bronson
2010-12-08  8:06           ` Return Stephen J. Turnbull
2010-12-08 20:51             ` Return Samuel Bronson
  -- strict thread matches above, loose matches on Subject: below --
2010-12-12  4:49 Keyword args (was: Return) MON KEY

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m27hfi1025.fsf_-_@gmail.com \
    --to=eller.helmut@gmail.com \
    --cc=emacs-devel@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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.