From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rivka Miller Newsgroups: gmane.emacs.help Subject: Re: `list-of' macro snippet [regarding Comprehensions] Date: Sat, 3 Nov 2012 14:57:46 -0700 (PDT) Message-ID: <556673a6-b350-49cc-905d-0662222ca071@g8g2000yqp.googlegroups.com> References: <44777946-db62-48fa-9e99-2fd06c6d296c@g18g2000vbf.googlegroups.com> <87pq3vmlg5.fsf@informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1351980017 3114 80.91.229.3 (3 Nov 2012 22:00:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 3 Nov 2012 22:00:17 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 03 23:00:26 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TUllQ-0008Sb-4h for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Nov 2012 23:00:24 +0100 Original-Received: from localhost ([::1]:35453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUllF-0006Zb-VX for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Nov 2012 18:00:13 -0400 Original-Received: by 10.224.219.144 with SMTP id hu16mr3068853qab.1.1351979867022; Sat, 03 Nov 2012 14:57:47 -0700 (PDT) Original-Received: by 10.236.128.198 with SMTP id f46mr367794yhi.7.1351979866986; Sat, 03 Nov 2012 14:57:46 -0700 (PDT) Original-Path: usenet.stanford.edu!c7no4986614qap.0!news-out.google.com!gf5ni18188417qab.0!nntp.google.com!c7no5159590qap.0!postnews.google.com!g8g2000yqp.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.sources, gnu.emacs.help, comp.emacs, comp.lang.lisp, comp.lang.functional Complaints-To: groups-abuse@google.com Injection-Info: g8g2000yqp.googlegroups.com; posting-host=99.42.77.127; posting-account=V5Tx-QoAAACNTDxOswIwdOklJAUE-vym Original-NNTP-Posting-Host: 99.42.77.127 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20100101 Firefox/12.0,gzip(gfe) Injection-Date: Sat, 03 Nov 2012 21:57:47 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.sources:13608 gnu.emacs.help:195200 comp.emacs:102689 comp.lang.lisp:311693 comp.lang.functional:69679 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:87529 Archived-At: On Nov 2, 8:09=A0pm, "Pascal J. Bourguignon" wrote: > Rivka Miller writes: > > This is not that hard. > > > You can take the defmacro =A0comp out of the defun. > > > It should not be hard > > ---------------------------------------- > > background info in gnu.emacs.help > > > I spent a few hours poring over and fixed some of the variables and > > backquotes and character codes. > > > The defmacro is now only nested in one function where it is needed. > > Hope, someone can help get it to work and produce some kind of demo > > examples. > > > (defun open-bracket (stream ch) > > > =A0 (defmacro comp ((e &rest qs) l2) > > =A0 =A0 (if (null qs) `(cons ,e ,l2) =A0 =A0 =A0 =A0; rule A > > =A0 =A0 =A0 (let ((q1 (car qs)) > > =A0 =A0 =A0 =A0 =A0 =A0 (q (cdr qs))) > > =A0 =A0 =A0 =A0 (if (not(eq (cadr q1) '<-)) =A0; a generator? > > =A0 =A0 =A0 =A0 =A0 =A0 `(if ,q1 (comp (,e ,@q),l2) ,l2) ; rule B > > =A0 =A0 =A0 =A0 =A0 (let ((v (car q1)) =A0 =A0 =A0 =A0 =A0 =A0; rule C > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (l1 (third q1)) > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (h (gentemp "H-")) > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (us (gentemp "US-")) > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (us1 (gentemp "US1-"))) > > =A0 =A0 =A0 =A0 =A0 =A0 `(labels ((,h (,us) =A0 =A0 =A0 =A0 ; correspon= ds to a letrec > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (if (null ,us) ,l2 > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (let ((,v (car = ,us)) > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (,u= s1 (cdr ,us))) > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (comp (,e ,= @q) (,h ,us1)))))) > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(,h ,l1))))))) > > > =A0 (do ((l nil) > > =A0 =A0 =A0 =A0(c (read stream t nil t)(read stream t nil t))) > > =A0 =A0 =A0 ((eq c '|]|) `(comp ,(reverse l) ())) > > =A0 (push c l)) > > ) > > > (defun closing-bracket (stream ch) '|]|) > > > (eval-when (compile load eval) > > =A0 (set-macro-character #\[ #'open-bracket) > > =A0 (set-macro-character #\] #'closing-bracket)) > > Why are you repeating this code here in comp.lang.lisp? > > I already told you that it was nonsensical! > > When you put the defmacro for inside the defun, it may not have > compile-time effects. =A0Therefore when you compile a file containing > brackets, the reader macro function will be called, the macro will be > defined, but maybe only into the run-time environment, not into the > compilation environment. =A0Therefore the compiler may not know that COMP > is a macro, and it may very well signal an error when compiling a > bracket expression! > > Why do you insist putting the defmacro inside the defun? You must have read in a hurry. In previous post, I actually said >> You can take the defmacro comp out of the defun. Now, you can take it out and try to run it in emacs and put some run examples. R