Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.functional > #442
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | "Pascal J. Bourguignon" <pjb@informatimago.com> |
| Newsgroups | gnu.emacs.sources, gnu.emacs.help, comp.emacs, comp.lang.lisp, comp.lang.functional |
| Subject | Re: `list-of' macro snippet [regarding Comprehensions] |
| Date | Sat, 03 Nov 2012 04:09:30 +0100 |
| Organization | Informatimago |
| Lines | 67 |
| Message-ID | <87pq3vmlg5.fsf@informatimago.com> (permalink) |
| 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> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| X-Trace | individual.net fi3eL/1QeT12di/tqD61jAYeFCH8POVLmSTxbMjA6nbERgNA8gaBs/SRbva9gmIKNM |
| Cancel-Lock | sha1:MjY3ZTY3NzM3MTExMjc1OGRjMjMzY2ViNmRjOGUzMGUzYjBmMTk3Zg== sha1:zZAOhIl7jWv8UoensWY8nFrw0co= |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== |
| X-Accept-Language | fr, es, en |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.4 (darwin) |
| Xref | csiph.com comp.emacs:1610 comp.lang.lisp:11895 comp.lang.functional:442 |
Cross-posted to 5 groups.
Show key headers only | View raw
Rivka Miller <rivkaumiller@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? -- __Pascal Bourguignon__ http://www.informatimago.com
Back to comp.lang.functional | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: `list-of' macro snippet [regarding Comprehensions] Rivka Miller <rivkaumiller@gmail.com> - 2012-11-02 19:06 -0700
Re: `list-of' macro snippet [regarding Comprehensions] "Pascal J. Bourguignon" <pjb@informatimago.com> - 2012-11-03 04:09 +0100
Re: `list-of' macro snippet [regarding Comprehensions] Rivka Miller <rivkaumiller@gmail.com> - 2012-11-03 14:57 -0700
Re: `list-of' macro snippet [regarding Comprehensions] Rivka Miller <rivkaumiller@gmail.com> - 2012-11-07 09:08 -0800
Re: `list-of' macro snippet [regarding Comprehensions] "Pascal J. Bourguignon" <pjb@informatimago.com> - 2012-11-07 23:30 +0100
csiph-web