From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jon Strait Newsgroups: gmane.emacs.help Subject: Expected behavior of CL special forms, 'labels' and 'flet', inside macros. Date: Mon, 03 Aug 2009 01:04:44 -0700 Message-ID: <4A769A1C.4050401@moonloop.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1249346546 11229 80.91.229.12 (4 Aug 2009 00:42:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 4 Aug 2009 00:42:26 +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 Aug 04 02:42:19 2009 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 1MY86b-0003DM-WC for geh-help-gnu-emacs@m.gmane.org; Tue, 04 Aug 2009 02:42:18 +0200 Original-Received: from localhost ([127.0.0.1]:57341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MY86b-00084X-98 for geh-help-gnu-emacs@m.gmane.org; Mon, 03 Aug 2009 20:42:17 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MXsdP-0000hX-OZ for help-gnu-emacs@gnu.org; Mon, 03 Aug 2009 04:11:07 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MXsdK-0000hD-9i for help-gnu-emacs@gnu.org; Mon, 03 Aug 2009 04:11:06 -0400 Original-Received: from [199.232.76.173] (port=38537 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MXsdK-0000hA-69 for help-gnu-emacs@gnu.org; Mon, 03 Aug 2009 04:11:02 -0400 Original-Received: from smtp.novuscom.net ([216.19.176.3]:40013 helo=novuscom.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MXsdJ-0006ch-AC for help-gnu-emacs@gnu.org; Mon, 03 Aug 2009 04:11:01 -0400 Original-Received: (qmail 26340 invoked from network); 3 Aug 2009 08:10:46 -0000 Original-Received: from 216-19-179-189.dyn.novuscom.net (HELO [192.168.0.101]) ([216.19.179.189]) (envelope-sender ) by smtp.novuscom.net (qmail-ldap-1.03) with SMTP for ; 3 Aug 2009 08:10:46 -0000 User-Agent: Thunderbird 2.0.0.19 (X11/20090213) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Mailman-Approved-At: Mon, 03 Aug 2009 19:54:34 -0400 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:66711 Archived-At: Hello, I thought I'd run this issue by the list in case someone who's worked on the CL extension code can say that it's the proper behavior and not worth submitting a bug report on. Basically, I tried using a 'labels' form to bind a function inside a macro to be used recursively and it wasn't working. (Lisp nesting exceeds max error) Then, I switched the 'labels' with 'flet', which ended up working fine, but not until after having to change the binding name as well. Using the same name for 'flet' as was previous used for 'labels' resulted in this strange error: "Use `labels', not `flet', to rebind macro names" Is seems for some reason, the 'labels' functions binding name was registered with a macro name as well. Be advised, this is only in the context of testing both the macro and the calling code with eval-last-sexp inside a buffer. For the sample macro I created below, the first argument is a list of items and every subsequent argument is a lambda function taking one argument, to apply in sequence to the initial argument list using mapcar: (defmacro map-chain (init-list &rest mfuncs) (setq mfuncs (reverse mfuncs)) (flet ((fmap (init-list mfuncs) (if (null mfuncs) init-list `(mapcar ,(car mfuncs) ,(fmap init-list (cdr mfuncs)))))) (fmap init-list mfuncs))) (map-chain '(7 8 9) (lambda (x) (* x 10)) (lambda (y) (+ y 4))) I'm currently using Emacs 23.0.92 Thanks, Jon