[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: m4sugar speedups
From: |
Eric Blake |
Subject: |
Re: m4sugar speedups |
Date: |
Fri, 26 Oct 2007 06:31:19 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Benoit SIGOURE on 10/26/2007 12:56 AM:
>> address@hidden m4_car (@var{list})
>> address@hidden
>> +Expands to the quoted first element of the comma-separated quoted
>> address@hidden Often used with @code{m4_cdr} to recursively iterate
>> +through a list. Generally, when using quoted lists of quoted elements,
>> address@hidden should be called without any extra quotes.
>> address@hidden defmac
>> +
>> address@hidden m4_cdr (@var{list})
>> address@hidden
>> +Expands to a quoted list of all but the first element of the
>> +comma-separated quoted @var{list}, or the empty string if @var{list} had
>> +only one element. Generally, when using quoted lists of quoted
>> +elements, @code{m4_cdr} should be called without any extra quotes.
>
> May I ask why `car' and `cdr'?
Pre-existing macro names, already in use (even though they were
undocumented) by at least libtool. I suppose we could choose better names
(m4_first and m4_rest), and keep the m4_car and m4_cdr name as
undocumented aliases. Plus the terms car and cdr have a history in lisp
programming, and m4sugar tends to look distantly related to lisp (hmm,
even 'info elisp "list elements"' fails to give a history behind these
names :( But wikipedia does: http://en.wikipedia.org/wiki/CAR_and_CDR.
The names go back to the 50s (way before my time!) because of the
'contents of address register' and 'contents of decrement register' on the
IBM 704 machine).
>> address@hidden
>> +m4_define([m4_map], [m4_if([$2], [[]], [], [_$0($@@)])])dnl
>> +m4_define([_m4_map], [m4_ifval([$2],
>> + [$1(m4_unquote(m4_car($2)))[]$0([$1], m4_cdr($2))])])dnl
>> +m4_map([ m4_eval], [[1],[1+1]])
> ^
> Why is there a space here? I'm just asking :D
So that the result will be " 1 2" and not "12". Plus, to emphasize that
m4_indir would invoke the macro named " m4_eval", while m4_map/m4_apply
output a literal " " followed by the invocation of "m4_eval". Do I need
to add more words along those lines here?
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHId4W84KuGfSFAYARAvH7AKC4cGZv/QdzbLuCtF6dXuLd352vaQCfTJwy
SR5mY8qVsYhhWri9c7iIHpY=
=kKpd
-----END PGP SIGNATURE-----