[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iterating over arguments

From: Sam Steingold
Subject: Re: iterating over arguments
Date: Mon, 14 Sep 2009 16:20:02 -0400
User-agent: Thunderbird (X11/20090625)

Eric Blake wrote:
Sam Steingold <sds <at>> writes:

(drop m4_popdef, replace m4_pushdef with m4_define)

m4_pushdef/m4_popdef is nicer than m4_define, in that your use of the macro name becomes a local variable (you aren't corrupting state if anything else in the happened to use the same name for an unrelated macro). But m4_define works all right if you have no reason to suspect that the macro name will ever collide.


I thought that I was modifying a local variable.

(defun foo (bar)
  (setq bar (1+ bar)) ; modify a local binding; no effect outside of foo
  (print bar))

[1]> (defparameter bar 1)
[2]> (defun foo (bar) (incf bar) (print bar))
[3]> bar
[4]> (foo 10)

[5]> bar

you appear to imply that

m4_foreach_w([cl_feat], [$1],
[ m4_define([cl_feat], ...) ])

leaks cl_feat outside of m4_foreach_w?

  m4_foreach_w([cl_feat], [$1],
-[m4_pushdef([CL_FEAT], m4_toupper(cl_feat))dnl
-AC_CACHE_CHECK([for CL_FEAT in CLISP], [cl_cv_clisp_]cl_feat,
+[m4_define([cl_feat], m4_toupper(cl_feat))dnl
+AC_CACHE_CHECK([for cl_feat in CLISP], [cl_cv_clisp_]cl_feat,

But if you are ALWAYS going to use the upper case version, then why not skip the m4_define altogether and do the upper-casing up front?

m4_foreach_w([cl_feat], m4_toupper([$1]),
[AC_CACHE_CHECK([for cl_feat in CLISP], ....

even better! will use this!

Thanks a lot!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]