[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch
From: |
Gary V . Vaughan |
Subject: |
Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch |
Date: |
Tue, 16 Sep 2003 09:17:21 +0100 |
On Monday, September 15, 2003, at 09:21 pm, Paul Eggert wrote:
they are none-the-less genuinely useful shorthand that can't be done
without macros. Do you have a similar replacement functionality in
mind? Or do you find macros like these to be worse than the extra
typing that would be required in their absence?
Yes, because code is clearer when function-like macros act like
functions.
Also, less typing is often required if you avoid the macros. For
example, compare this code (taken from GNU m4):
new = XMALLOC (macro_definition, 1);
to this proposed replacement:
new = xmalloc (sizeof *new);
The latter style is shorter in this case. (In other cases it's
longer, of course.) Another advantage of the latter style is that
it's immune to changes in the type of the variable.
Okay, sold! Thanks for the explanation :-)
Here's a proposed patch to GNU m4 to let it survive the loss of the
macros in question, so that you can see how much the code is actually
affected.
It is surprising to see how little effect it has in practice, I have to
say. Once the free module is in gnulib, I'll resynch m4 and apply your
patch. Thanks again!
Aside: I notice that m4, after the proposed patch, uses calloc (1, S)
a lot. Perhaps we should define a new zalloc (S) that is equivalent
to calloc (1, S), for convenience? I've used zalloc in other
programs.
If zalloc (S) === xcalloc (1, S), that would be cool. Failing that we
could always add an XZALLOC macro... :-b
Cheers,
Gary.
--
())_. Gary V. Vaughan gary@(oranda.demon.co.uk|gnu.org)
( '/ Research Scientist http://www.oranda.demon.co.uk
,_())____
/ )= GNU Hacker http://www.gnu.org/software/libtool \'
`&
`(_~)_ Tech' Author http://sources.redhat.com/autobook
=`---d__/
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, (continued)
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Bruno Haible, 2003/09/10
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Paul Eggert, 2003/09/11
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Paul Eggert, 2003/09/11
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Gary V. Vaughan, 2003/09/11
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Paul Eggert, 2003/09/12
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Jim Meyering, 2003/09/13
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Gary V. Vaughan, 2003/09/15
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Paul Eggert, 2003/09/15
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch,
Gary V . Vaughan <=
- [Bug-gnulib] Re: Patch proposal: 1-gary-safe-xfree.patch, Simon Josefsson, 2003/09/16
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Bruno Haible, 2003/09/15
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Paul Eggert, 2003/09/15
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Bruno Haible, 2003/09/15
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Gary V. Vaughan, 2003/09/19
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Paul Eggert, 2003/09/22
Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Gary V . Vaughan, 2003/09/11
Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Karl Berry, 2003/09/10