This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Optimzed vs. readable code
- From: Ian Lance Taylor <ian at airs dot com>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: 01 Dec 2005 09:15:47 -0800
- Subject: Re: Optimzed vs. readable code
- References: <pan.2005.11.29.16.48.37.733665@levallois.eu.org> <F2B5F487-EF4D-43E4-B2D2-AD7EA914F24F@apple.com> <pan.2005.11.29.22.27.59.180878@levallois.eu.org> <4348dea50511300918w1a9a9ad1g@mail.gmail.com> <20051130173343.GD18129@bateleur.arcanes.fr.eu.org> <m3k6epvocb.fsf@uniton.integrable-solutions.net> <20051201114418.GC11500@bateleur.arcanes.fr.eu.org> <m3psohx8np.fsf@uniton.integrable-solutions.net>
Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
> http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2004/n1614.pdf
Interesting, but it doesn't seem to describe:
#scope
#define COMB ::
#define combine(a,b) a::b
#export combine
#endscope
#define COMB quux
int x = combine(foo,bar);
Has this issue been discussed anywhere?
How should it work? In the above example, it seems clear that combine
should be rewritten internally to refer to a renamed, private, version
of COMB.
But that would prohibit a capability which currently exists, to have a
macro refer another macro and to have the code #undef and #define that
other macro. For example:
#scope
#define EFUNC standard_error
#define CHECK(x) ((x) || EFUNC (__FILE__, __LINE__))
#export CHECK
#endscope
CHECK(foo);
#undef EFUNC
#define EFUNC my_error
CHECK(bar);
We could argue that this will only work as desired if we #export
EFUNC. Then we would have to make sure to only rewrite CHECK to use a
private version of EFUNC if EFUNC is not #exported. That's slightly
nasty since at the time of the #define of CHECK we don't know whether
or not EFUNC is exported.
It gets nastier if we have nested scopes. We might #export both CHECK
and EFUNC to the enclosing scope, but then only #export CHECK to the
next enclosing scope. That would imply that we have to rewrite CHECK
again when the enclosing scope closes.
Generally a cool idea, though.
Ian