help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing a function/macro in Elisp that generates a function at runti


From: Toby Cubitt
Subject: Re: Writing a function/macro in Elisp that generates a function at runtime
Date: Tue, 28 Oct 2008 18:21:20 +0100
User-agent: Thunderbird 2.0.0.17 (X11/20080929)

Johan Bockgård wrote:
> Toby Cubitt <tsc25@cantab.net> writes:
> 
>> (defun wrap-insert-function (insfun)
>>   `(lambda (new-data old-cell)
>>      (setf (cell-data old-cell)
>>            (funcall ,insfun new-data (cell-data old-cell)))
>>      old-cell))
> 
> (lexical-let ((insfun insfun))
>   (lambda ...))

Hah! I knew I could do it with closures, and I knew elisp didn't have
them, and I completely forgot that the CL package provided a way of
simulating them. Thanks a lot!

I expect anything else I could come up with would end up being an
ad-hoc, informally-specified, bug-ridden, slow implementation of half of
lexical-let :)

Out of sheer stubborn curiosity, I'd still like to know whether macros
can be used to generate backquote constructs programmatically...

Toby




reply via email to

[Prev in Thread] Current Thread [Next in Thread]