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: Wed, 7 Nov 2012 09:08:14 -0800 (PST) Message-ID: <3445356f-5bb8-4dcd-bd45-d98a4e103a2a@g18g2000vbf.googlegroups.com> References: <44777946-db62-48fa-9e99-2fd06c6d296c@g18g2000vbf.googlegroups.com> <87pq3vmlg5.fsf@informatimago.com> <556673a6-b350-49cc-905d-0662222ca071@g8g2000yqp.googlegroups.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 1352308214 19831 80.91.229.3 (7 Nov 2012 17:10:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 7 Nov 2012 17:10:14 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 07 18:10:24 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 1TW98w-00073u-KY for geh-help-gnu-emacs@m.gmane.org; Wed, 07 Nov 2012 18:10:22 +0100 Original-Received: from localhost ([::1]:55213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TW98n-0004Wl-9L for geh-help-gnu-emacs@m.gmane.org; Wed, 07 Nov 2012 12:10:13 -0500 Original-Received: by 10.224.205.65 with SMTP id fp1mr3662023qab.4.1352308094541; Wed, 07 Nov 2012 09:08:14 -0800 (PST) Original-Received: by 10.52.34.205 with SMTP id b13mr1166873vdj.3.1352308094256; Wed, 07 Nov 2012 09:08:14 -0800 (PST) Original-Path: usenet.stanford.edu!c7no10035645qap.0!news-out.google.com!gf5ni18188417qab.0!nntp.google.com!c7no10379680qap.0!postnews.google.com!g18g2000vbf.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: g18g2000vbf.googlegroups.com; posting-host=99.113.167.238; posting-account=V5Tx-QoAAACNTDxOswIwdOklJAUE-vym Original-NNTP-Posting-Host: 99.113.167.238 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: Wed, 07 Nov 2012 17:08:14 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.sources:13616 gnu.emacs.help:195245 comp.emacs:102699 comp.lang.lisp:311768 comp.lang.functional:69684 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:87573 Archived-At: On Nov 3, 1:57=A0pm, Rivka Miller wrote: > 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 ; corresp= onds to a letrec > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (if (null ,us) ,l= 2 > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (let ((,v (ca= r ,us)) > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (= ,us1 (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 CO= MP > > 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 =A0comp out of the defun. > > Now, you can take it out and try to run it in emacs and put some run > examples. > > R I still need someone to help me get the common-lisp comprehension code working on emacs.