From: Mark DePristo
Subject: Default key value?
Date: 
Message-ID: <33C2DBA5.767A6FBD@nwu.edu>
I'd like to define a procedure -- not the actual function.  I'd like to
allow a keyword argument KEY such that KEY is applied to arg1 before
arg1 is process.  However, I can't seem to figure out the value I should
use for the INITFORM of key in the argument list.  Ideally, KEY will
have a initform that will not have any affect on arg1.  How is this
traditionally done in Lisp?  Thanks.

(defun proc (arg1 &key (key #'INITFORM))
    (...(key arg1))

--

-------------------------
Mark A. DePristo
··········@nwu.edu
http://osiris.res-hall.nwu.edu/

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.6.2

mQCNAzNfvt4AAAEEAMmJsOWRlRfc1xVYxf1/ioAHRJzpjlzT/6dudTtsqR9Ciflt
k+gEXQ+sWjGPpmzupU40zXUVrVOfu2Cvd3Nf/EMDThUuHQGHMh5Wurae3hglPoG7
kOZ4sEt4YqSamDv1EIQ/0p2YRSqIPQXrf4HVmyRBjOxwxyOkJqF5Hvi/LFStAAUR
tCVNYXJrIEEuIERlUHJpc3RvIDxtLWRlcHJpc3RvQG53dS5lZHU+
=tRFR
-----END PGP PUBLIC KEY BLOCK-----
-------------------------

From: Barry Margolin
Subject: Re: Default key value?
Date: 
Message-ID: <5q2ucs$eci@tools.bbnplanet.com>
In article <·················@nwu.edu>,
Mark DePristo  <··········@nwu.edu> wrote:
>(defun proc (arg1 &key (key #'INITFORM))
>    (...(key arg1))

The problem isn't with the defaulting, that's fine.  The problem is with
the way you're calling the key function.  It should be (funcall key arg1).
This is Common Lisp, not Scheme, so the functional position in a form is
not evaluated.

-- 
Barry Margolin, ······@bbnplanet.com
BBN Corporation, Cambridge, MA
Support the anti-spam movement; see <http://www.cauce.org/>
From: Thomas A. Russ
Subject: Re: Default key value?
Date: 
Message-ID: <ymiiuyiyk77.fsf@sevak.isi.edu>
In article <·················@nwu.edu> Mark DePristo <··········@nwu.edu> writes:

 > 
 > I'd like to define a procedure -- not the actual function.  I'd like to
 > allow a keyword argument KEY such that KEY is applied to arg1 before
 > arg1 is process.  However, I can't seem to figure out the value I should
 > use for the INITFORM of key in the argument list.  Ideally, KEY will
 > have a initform that will not have any affect on arg1.  How is this
 > traditionally done in Lisp?  Thanks.
 > 
 > (defun proc (arg1 &key (key #'INITFORM))
 >     (...(key arg1))
 > 

Assuming I understand what you are trying to do, consider:

   (defun proc (arg1 &key (key #'identity))
     (...  (funcall key arg1) ...))

-- 
Thomas A. Russ,  USC/Information Sciences Institute          ···@isi.edu    
From: Kelly Murray
Subject: Re: Default key value?
Date: 
Message-ID: <5qj23j$mu8$1@sparky.franz.com>
In article <·················@nwu.edu>, Mark DePristo <··········@nwu.edu> writes:
>> I'd like to define a procedure -- not the actual function.  I'd like to
>> allow a keyword argument KEY such that KEY is applied to arg1 before
>> arg1 is process.  However, I can't seem to figure out the value I should
>> use for the INITFORM of key in the argument list.  Ideally, KEY will
>> have a initform that will not have any affect on arg1.  How is this
>> traditionally done in Lisp?  Thanks.
>> 
>> (defun proc (arg1 &key (key #'INITFORM))
>>     (...(key arg1))
>> 

#'identity  is what you should use for the default key function.
It simply returns its argument, and is implicitly used for the :key
value for all the CL sequence functions.  
However, an actual implementation would probably not be done this way.
BTW, you need to use FUNCALL to call the key function.

(defun proc (arg1 &key (key #'identity))
   (... (funcall key arg1)))
   

-Kelly Murray  ···@franz.com  http://www.franz.com