all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Toby Cubitt <tsc25@cantab.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Writing a function/macro in Elisp that generates a function at runtime
Date: Tue, 28 Oct 2008 18:21:20 +0100	[thread overview]
Message-ID: <49074A10.805@dr-qubit.org> (raw)
In-Reply-To: <yoijbpx4r3q8.fsf@remote1.student.chalmers.se>

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	other threads:[~2008-10-28 17:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-27 13:30 Writing a function/macro in Elisp that generates a function at runtime Toby Cubitt
2008-10-28 18:09 ` Johan Bockgård
2008-10-28 17:21   ` Toby Cubitt [this message]
     [not found] <mailman.2216.1225168079.25473.help-gnu-emacs@gnu.org>
2008-10-28  5:56 ` Barry Margolin
2008-10-28 10:38   ` Toby Cubitt
2008-10-28 12:42     ` Toby Cubitt
     [not found]     ` <mailman.2265.1225201433.25473.help-gnu-emacs@gnu.org>
2008-10-28 16:47       ` Ted Zlatanov
2008-10-28 17:10         ` Toby Cubitt

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=49074A10.805@dr-qubit.org \
    --to=tsc25@cantab.net \
    --cc=help-gnu-emacs@gnu.org \
    --cc=toby-dated-1225650084.771810@dr-qubit.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.