autoconf-patches
[Top][All Lists]
Advanced

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

naming m4_transform [was: faster AS_IF,AS_CASE]


From: Eric Blake
Subject: naming m4_transform [was: faster AS_IF,AS_CASE]
Date: Sat, 11 Oct 2008 08:18:01 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080914 Thunderbird/2.0.0.17 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Ralf Wildenhues on 8/16/2008 3:02 AM:
>>>> Also, should it be named slightly differently since it behaves more
>>>> like m4_map than m4_foreach?
>>> m4_map_pair maybe?
>> I went with the name m4_transform_pair, since it turned out to be very
>> easy to add m4_transform with similar semantics but visiting one argument
>> at a time.
> 
> Isn't there precedence in lisp for this kind of functionality,
> where we can reuse names from?

In emacs and in perl, the name "map" is closest to what m4_transform is
doing - taking a code snippet and a list, and applying each element (or
pair of elements, for m4_transform_pair) of the list in turn as the
argument to the code snippet.  But m4_map is already taken, where it is
passing an entire argument list to the code snippet, rather than a single
argument, and with the list of lists provided as a single argument.

For an example, these have the same behavior:

m4_map([m4_echo], [[[one]], [[two]], [[three]]])
m4_transform([m4_echo], [one], [two], [three])

At any rate, I'm interested in documenting these macros, as well as adding
a counterpart macro for m4_set iteration (the recent
_AS_DETECT_BETTER_SHELL change can be sped up).  It turns out that m4 is
more efficient when you pass the list element as an argument to a macro
invocation than it is with m4_foreach semantics of doing m4_define of the
list element to a temporary name, then doing m4_defn of that temporary
name to get back to the list element.  I originally went with the name
m4_transform because m4_map was taken, but maybe m4_map_each and
m4_map_pair might make more sense?

Any thoughts on whether I should rename m4_transform before documenting
it, and if so, to what?

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjwtZkACgkQ84KuGfSFAYDbzQCeLduYmz5csd/mNCqvGYF+56yi
l1oAoJEKP+GiLWMesgnwxRq3BCpnyMJ1
=Ln4S
-----END PGP SIGNATURE-----




reply via email to

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