unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Pascal J. Bourguignon" <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Evaluation of macro arguments
Date: Tue, 05 Jan 2016 20:22:17 +0100	[thread overview]
Message-ID: <87h9irn85y.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: 87fuycs35f.fsf@mbork.pl

Marcin Borkowski <mbork@mbork.pl> writes:

> Hi all,
>
> continuing my quest to grok macro argument evaluation issues, I'd like
> (again) to make sure that I get it correctly.  So I have this simple
> macro generating a list of consecutive numbers (which is not without
> problems - I am aware of those, namely (i) it uses hard-coded symbols
> instead of generating them on the fly, and (ii) it has no error
> checking):
>
> (defmacro range (from dir to)
>   `(let ((delta (cond ((eq ',dir 'upto) 1)
>                       ((eq ',dir 'downto) -1)))
>          (i ,from)
>          (list nil))
>      (while (not (= i ,to))
>        (push i list)
>        (setq i (+ i delta)))
>      (nreverse list)))

(let ((i 0))
   (list (range  i 'upto (incf i 10))  ; bam!
         i))

I hope you may debug it well.


-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk




  parent reply	other threads:[~2016-01-05 19:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-05 10:59 Evaluation of macro arguments Marcin Borkowski
2016-01-05 12:55 ` Stefan Monnier
2016-01-13 22:16   ` Marcin Borkowski
2016-01-14 13:47     ` Stefan Monnier
2016-01-14 20:32       ` Marcin Borkowski
2016-01-14 23:05         ` Stefan Monnier
2016-01-05 19:22 ` Pascal J. Bourguignon [this message]
2016-01-05 19:39   ` Marcin Borkowski
2016-01-05 20:30     ` Marcin Borkowski
     [not found]     ` <mailman.1794.1452025850.843.help-gnu-emacs@gnu.org>
2016-01-08 23:13       ` duthen.mac.01

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87h9irn85y.fsf@kuiper.lan.informatimago.com \
    --to=pjb@informatimago.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).