[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Making a lambda-expr more like a fn
- To: rik@cs.UCSD.EDU (Rik Belew)
- Subject: Re: Making a lambda-expr more like a fn
- From: bill@cambridge.apple.com (Bill St. Clair)
- Date: Mon, 16 Nov 1992 10:33:40 -0600
- Cc: Ranson <ranson@LANNION.cnet.fr>, info-mcl
At 23:03 11/15/92 -0800, Rik Belew wrote:
>One of the changes to CL2 that bit me has been that
>raw lambda's can no longer be funcall'd (or apply'd)
>directly.
>
>With CMULisp, I have remedied this by coercing the lambda
>into a function first:
>
> (setf (org-lexpr p) (coerce lexpr 'function))
>
>But CCL::COERCE-TO-FUNCTION won't have it:
>
>
>> Error: value (LAMBDA (WLIST &AUX X1) (SETQ X1 (NTH 0 HISTORY)) (VALUES (+ (CAR WLIST) (* (NTH 1 WLIST) X1)) (LIST 1.0 X1))) is not of the expected type FUNCTION.
>> While executing: CCL::COERCE-TO-FUNCTION
>
>I have also tried prepending the #' (function) abbrev., but
>that result couldn't be funcalled either.
>
>I was able to get what I wanted compiling the form instead. However, in
>this application, I would like very much to avoid the compilation overhead
>if at all possible. Can I?
At 11:28 11/16/92 +0000, Ranson wrote:
>Only the evaluator and the compiler process #' to create a function. If you
>don't want to compile, call EVAL.
>Or better, try to not create functions at run time.
> Daniel.
Daniel is correct. COERCE will either call COMPILE or do preprocessing for
EVAL depending on the value of *compile-definitions*. The problem with
COERCE is a known compiler bug. Compiling the expression:
(coerce x 'function)
results in a call to ccl::coerce-to-function. It should result in a call to
ccl::coerce-to-function-1. You can fix this in a number of ways:
1) Take Daniel's advice and don't try to create functions at run time.
2) Ask me to send you "coerce-to-function-patch"
This patch will be part of patch 2 for MCL 2.0.
3) write (funcall 'coerce x 'function) instead of (coerce x 'function)
This will be slightly slower than option 2, but I doubt you'll notice.