From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Toby Cubitt Newsgroups: gmane.emacs.help Subject: Re: Writing a function/macro in Elisp that generates a function at runtime Date: Tue, 28 Oct 2008 18:21:20 +0100 Message-ID: <49074A10.805@dr-qubit.org> References: <4905C265.1080907@dr-qubit.org> Reply-To: Toby Cubitt NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1225218167 7134 80.91.229.12 (28 Oct 2008 18:22:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 28 Oct 2008 18:22:47 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 28 19:23:49 2008 connect(): Connection refused Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KutEK-0008G7-JE for geh-help-gnu-emacs@m.gmane.org; Tue, 28 Oct 2008 19:23:48 +0100 Original-Received: from localhost ([127.0.0.1]:53842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KutDE-0001wy-4M for geh-help-gnu-emacs@m.gmane.org; Tue, 28 Oct 2008 14:22:40 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KutCl-0001s7-Lm for help-gnu-emacs@gnu.org; Tue, 28 Oct 2008 14:22:11 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KutCk-0001rL-0B for help-gnu-emacs@gnu.org; Tue, 28 Oct 2008 14:22:11 -0400 Original-Received: from [199.232.76.173] (port=49680 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KutCj-0001rD-Rh for help-gnu-emacs@gnu.org; Tue, 28 Oct 2008 14:22:09 -0400 Original-Received: from mail.geekisp.com ([216.168.135.169]:37164 helo=starfish.geekisp.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KutCi-00089W-JX for help-gnu-emacs@gnu.org; Tue, 28 Oct 2008 14:22:08 -0400 Original-Received: (qmail 5661 invoked by uid 1003); 28 Oct 2008 18:21:24 -0000 Original-Received: from www.geekisp.com (snackbar.int.geekisp.com [192.168.4.39]) by localhost.geekisp.com (tmda-ofmipd) with ESMTP; Tue, 28 Oct 2008 14:21:22 -0400 User-Agent: Thunderbird 2.0.0.17 (X11/20080929) In-Reply-To: X-Delivery-Agent: TMDA/1.1.11 (Ladyburn) X-Primary-Address: toby@dr-qubit.org X-detected-operating-system: by monty-python.gnu.org: OpenBSD 3.0-3.9 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:59215 Archived-At: Johan Bockgård wrote: > Toby Cubitt 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