Re: [pro] why :key arguments?

2011-07-05 Thread Pascal J. Bourguignon
Tamas Papp writes: > My problem with the key argument is that it complicates the interface. I > would like to use the same interface for sample statistics and random > variables, eg currently in CL-NUM-UTILS and CL-RANDOM I have If that complicates the interface then don't use them! &KEY are

Re: [pro] why :key arguments?

2011-07-05 Thread Marco Antoniotti
On Jul 5, 2011, at 11:51 , Tamas Papp wrote: > I am very happy to learn about these things. Currently I am working > on the algorithms and my main concern is to ensure correctness; speed > is secondary at this point, but even though I am not optimizing, I > want to keep my code optimizable later

Re: [pro] why :key arguments?

2011-07-05 Thread Tamas Papp
On Mon, 04 Jul 2011 20:11:56 +0300, Nikodemus Siivola wrote: > On 4 July 2011 19:42, Pascal J. Bourguignon > wrote: > >> I don't think so. > > I disagree strongly, and I'm pretty sure CLHS agrees with me, since it > goes to the trouble of specifying what happens with FUNCALL. > > CLHS, DEFINE-

Re: [pro] why :key arguments?

2011-07-04 Thread Nikodemus Siivola
On 4 July 2011 19:42, Pascal J. Bourguignon wrote: > I don't think so. I disagree strongly, and I'm pretty sure CLHS agrees with me, since it goes to the trouble of specifying what happens with FUNCALL. CLHS, DEFINE-COMPILER-MACRO: "The &whole argument is bound to the form argument that is pass

Re: [pro] why :key arguments?

2011-07-04 Thread Nikodemus Siivola
On 4 July 2011 16:11, Alessio Stalla wrote: > On Mon, Jul 4, 2011 at 3:09 PM, Pascal J. Bourguignon > wrote: >> Nikodemus Siivola >> writes: >> >>> On 4 July 2011 14:46, Stas Boukarev wrote: * They can't be used with APPLY or FUNCALL. >>> >>> Actually, they can be used with FUNCALL. >>> >

Re: [pro] why :key arguments?

2011-07-04 Thread Stas Boukarev
Nikodemus Siivola writes: > On 4 July 2011 14:46, Stas Boukarev wrote: > >> * They can't be used with APPLY or FUNCALL. > > Actually, they can be used with FUNCALL. I meant that it can be use with FUNCALL when it's called not on a known function. -- With best regards, Stas. _

Re: [pro] why :key arguments?

2011-07-04 Thread Nathan Froyd
On Mon, Jul 4, 2011 at 5:57 AM, Tamas Papp wrote: > I understand this.  My main question is: why not do this with compiler > macros?  Is there any reason for this, other than historical? 3.2.2.1.3 might offer some insight: "However, no language processor (compiler, evaluator, or other code walker

Re: [pro] why :key arguments?

2011-07-04 Thread Alessio Stalla
On Mon, Jul 4, 2011 at 3:09 PM, Pascal J. Bourguignon wrote: > Nikodemus Siivola > writes: > >> On 4 July 2011 14:46, Stas Boukarev wrote: >> >>> * They can't be used with APPLY or FUNCALL. >> >> Actually, they can be used with FUNCALL. >> >> (Otherwise, I echo pretty much everything that Stas s

Re: [pro] why :key arguments?

2011-07-04 Thread Pascal J. Bourguignon
Nikodemus Siivola writes: > On 4 July 2011 14:46, Stas Boukarev wrote: > >> * They can't be used with APPLY or FUNCALL. > > Actually, they can be used with FUNCALL. > > (Otherwise, I echo pretty much everything that Stas said.) > > Compiler-macros are, however, of decent tool for optimizing comm

Re: [pro] why :key arguments?

2011-07-04 Thread Nikodemus Siivola
On 4 July 2011 14:46, Stas Boukarev wrote: > * They can't be used with APPLY or FUNCALL. Actually, they can be used with FUNCALL. (Otherwise, I echo pretty much everything that Stas said.) Compiler-macros are, however, of decent tool for optimizing common cases of :KEY and :TEST arguments. Ch

Re: [pro] why :key arguments?

2011-07-04 Thread Pascal J. Bourguignon
Tamas Papp writes: > I would appreciate advice on this. I am especially interested in the > reason why some CL functions have :key arguments: is it because of > efficiency, backward-compatibility/history, or something else? The rationals for Common Lisp are generally explained in the first ch

Re: [pro] why :key arguments?

2011-07-04 Thread Stas Boukarev
Tamas Papp writes: > On Mon, 04 Jul 2011 14:20:32 +0400, Stas Boukarev wrote: > >> Tamas Papp writes: >> >>> On Mon, 04 Jul 2011 11:39:39 +0200, Hans Hübner wrote: >>> On Mon, Jul 4, 2011 at 11:31 AM, Tamas Papp wrote: > Why do some CL library functions have :key arguments? [...]

Re: [pro] why :key arguments?

2011-07-04 Thread Tamas Papp
On Mon, 04 Jul 2011 14:20:32 +0400, Stas Boukarev wrote: > Tamas Papp writes: > >> On Mon, 04 Jul 2011 11:39:39 +0200, Hans Hübner wrote: >> >>> On Mon, Jul 4, 2011 at 11:31 AM, Tamas Papp wrote: Why do some CL library functions have :key arguments? >>> [...] but it is a bit cumbersom

Re: [pro] why :key arguments?

2011-07-04 Thread Tamas Papp
On Mon, 04 Jul 2011 12:12:33 +0200, Svante Carl v. Erichsen wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Am 04.07.2011 11:31, schrieb Tamas Papp: >> Why do some CL library functions have :key arguments? >> >> I am asking because I am working on some statistics functions, and the

Re: [pro] why :key arguments?

2011-07-04 Thread Stas Boukarev
Tamas Papp writes: > On Mon, 04 Jul 2011 11:39:39 +0200, Hans Hübner wrote: > >> On Mon, Jul 4, 2011 at 11:31 AM, Tamas Papp >> wrote: >>> Why do some CL library functions have :key arguments? >> [...] >>> but it is a bit cumbersome.  I can make my code simpler by relying on >>> calls like >>> >

Re: [pro] why :key arguments?

2011-07-04 Thread Tamas Papp
On Mon, 04 Jul 2011 11:39:39 +0200, Hans Hübner wrote: > On Mon, Jul 4, 2011 at 11:31 AM, Tamas Papp > wrote: >> Why do some CL library functions have :key arguments? > [...] >> but it is a bit cumbersome.  I can make my code simpler by relying on >> calls like >> >> (quantiles (map 'vector key v

Re: [pro] why :key arguments?

2011-07-04 Thread Hans Hübner
On Mon, Jul 4, 2011 at 11:31 AM, Tamas Papp wrote: > Why do some CL library functions have :key arguments? [...] > but it is a bit cumbersome.  I can make my code simpler by relying on > calls like > > (quantiles (map 'vector key vector) quantiles) This not only conses "a bit more", it also dupli

[pro] why :key arguments?

2011-07-04 Thread Tamas Papp
Why do some CL library functions have :key arguments? I am asking because I am working on some statistics functions, and the design choice came up. Specifically, I can write functions like (defun quantiles (sequence quantiles &key (key #'identity)) ...) but it is a bit cumbersome. I can ma