Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion `list-of' macro snippet [regarding Comprehensions]

Received: by 10.224.205.65 with SMTP id fp1mr3662023qab.4.1352308094541;
        Wed, 07 Nov 2012 09:08:14 -0800 (PST)
MIME-Version: 1.0
Received: by 10.52.34.205 with SMTP id b13mr1166873vdj.3.1352308094256; Wed,
 07 Nov 2012 09:08:14 -0800 (PST)
Path: gf5ni18188417qab.0!nntp.google.com!c7no10379680qap.0!postnews.google.com!g18g2000vbf.googlegroups.com!not-for-mail
Newsgroups: gnu.emacs.sources,gnu.emacs.help,comp.emacs,comp.lang.lisp,comp.lang.functional
Date: Wed, 7 Nov 2012 09:08:14 -0800 (PST)
Complaints-To: groups-abuse@google.com
Injection-Info: g18g2000vbf.googlegroups.com; posting-host=99.113.167.238; posting-account=V5Tx-QoAAACNTDxOswIwdOklJAUE-vym
NNTP-Posting-Host: 99.113.167.238
References: <44777946-db62-48fa-9e99-2fd06c6d296c@g18g2000vbf.googlegroups.com>
 <b4135226-2e01-494a-bec7-6a215fdc723d@w2g2000vbc.googlegroups.com>
 <f9dfcdb2-9d1c-4307-8d1b-588760466ed3@b12g2000vbg.googlegroups.com>
 <d909bf45-a8b5-4974-8135-a101af3531d6@y6g2000vbb.googlegroups.com>
 <87pq3vmlg5.fsf@informatimago.com> <556673a6-b350-49cc-905d-0662222ca071@g8g2000yqp.googlegroups.com>
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)
Message-ID: <3445356f-5bb8-4dcd-bd45-d98a4e103a2a@g18g2000vbf.googlegroups.com>
Subject: Re: `list-of' macro snippet [regarding Comprehensions]
From: Rivka Miller <rivkaumil...@gmail.com>
Injection-Date: Wed, 07 Nov 2012 17:08:14 +0000
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Nov 3, 1:57=A0pm, Rivka Miller <rivkaumil...@gmail.com> wrote:
> On Nov 2, 8:09=A0pm, "Pascal J. Bourguignon" <p...@informatimago.com>
> wrote:
>
>
>
>
>
>
>
>
>
> > Rivka Miller <rivkaumil...@gmail.com> 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.