all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Rivka Miller <rivkaumiller@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: `list-of' macro snippet [regarding Comprehensions]
Date: Sat, 3 Nov 2012 14:57:46 -0700 (PDT)	[thread overview]
Message-ID: <556673a6-b350-49cc-905d-0662222ca071@g8g2000yqp.googlegroups.com> (raw)
In-Reply-To: 87pq3vmlg5.fsf@informatimago.com

On Nov 2, 8:09 pm, "Pascal J. Bourguignon" <p...@informatimago.com>
wrote:
> Rivka Miller <rivkaumil...@gmail.com> writes:
> > This is not that hard.
>
> > You can take the defmacro  comp 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)
>
> >   (defmacro comp ((e &rest qs) l2)
> >     (if (null qs) `(cons ,e ,l2)        ; rule A
> >       (let ((q1 (car qs))
> >             (q (cdr qs)))
> >         (if (not(eq (cadr q1) '<-))  ; a generator?
> >             `(if ,q1 (comp (,e ,@q),l2) ,l2) ; rule B
> >           (let ((v (car q1))            ; rule C
> >                 (l1 (third q1))
> >                 (h (gentemp "H-"))
> >                 (us (gentemp "US-"))
> >                 (us1 (gentemp "US1-")))
> >             `(labels ((,h (,us)         ; corresponds to a letrec
> >                           (if (null ,us) ,l2
> >                             (let ((,v (car ,us))
> >                                   (,us1 (cdr ,us)))
> >                               (comp (,e ,@q) (,h ,us1))))))
> >                (,h ,l1)))))))
>
> >   (do ((l nil)
> >        (c (read stream t nil t)(read stream t nil t)))
> >       ((eq c '|]|) `(comp ,(reverse l) ()))
> >   (push c l))
> > )
>
> > (defun closing-bracket (stream ch) '|]|)
>
> > (eval-when (compile load eval)
> >   (set-macro-character #\[ #'open-bracket)
> >   (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.  Therefore 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.  Therefore 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


  parent reply	other threads:[~2012-11-03 21:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <44777946-db62-48fa-9e99-2fd06c6d296c@g18g2000vbf.googlegroups.com>
2012-10-29  0:49 ` `list-of' macro snippet [regarding Comprehensions] Rivka Miller
2012-10-29  2:20   ` Rivka Miller
2012-11-03  2:06     ` Rivka Miller
2012-11-03  3:09       ` Pascal J. Bourguignon
     [not found]       ` <87pq3vmlg5.fsf@informatimago.com>
2012-11-03 21:57         ` Rivka Miller [this message]
2012-11-07 17:08           ` Rivka Miller
2012-11-07 22:30             ` Pascal J. Bourguignon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=556673a6-b350-49cc-905d-0662222ca071@g8g2000yqp.googlegroups.com \
    --to=rivkaumiller@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.