-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Eric Blake on 10/14/2008 5:31 PM: > But m4 doesn't make it easy to write anonymous functions. By making > m4_map_args supply the ( and ) around a single argument, I no longer have a > way > to inject $2 and $3 into the mapping function, at least, not without some > inefficiencies. I've thought about something like this (untested, and I'm > not > even sure I'm using the best naming convention):
I double checked wikipedia, and this is the right name: http://en.wikipedia.org/wiki/Currying > > # m4_curry(MACRO, ARG...) > # ----------------------- > # Can be used as a currying macro - the expansion of this macro expects > # to be expanded as another macro that takes one argument, which is then > # appended to the list of ARGs and passed to the invocation of MACRO. > # For example, > # m4_curry([m4_do], [1], [2])([3]) > # is identical to > # m4_do([1], [2], [3]) > m4_define([m4_curry], [$1(m4_shift($@), _$0]) > m4_define([_m4_curry], [[$1])]) and I got it right - subsequent testing confirmed that what I doodled in the email is the right implementation! m4_curry([m4_curry], [m4_reverse], [1])([2])([3]) => 3, 2, 1 so I'll be adding m4_curry to m4sugar, whether or not it ends up making a more efficient alternative to autoconf's use of m4_foreach_w. I just have to finish the testsuite addition and post the patch for review first. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -----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 iEYEARECAAYFAkj1efkACgkQ84KuGfSFAYDlgACePnWmmjOeGjioV5BrX6OBl/N7 qxYAmwbE4YZ+TeLyRV6n3kP6hrTG1+tW =9H9v -----END PGP SIGNATURE-----
