This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: c++ "with" keyword
- From: Erik Schnetter <schnetter at uni-tuebingen dot de>
- To: gcc at gcc dot gnu dot org
- Date: Sun, 29 Dec 2002 13:27:32 +0100
- Subject: Re: c++ "with" keyword
The example
struct S
{
int x;
int y;
};
int main()
{
S s;
with (s)
{
.x = 1;
.y = 2;
}
return 0;
}
can easily be rewritten by introducing temporary references, as in
int main()
{
S s;
{
S& t = s;
t.x = 1;
t.y = 2;
}
return 0;
}
This requires only one additional variable reference each time the
"with" object is used. Additionally, it allows several "with" objects
(with different names) at the same time. In C, the same thing can be
done by using pointers.
-erik
--
Erik Schnetter <schnetter@uni-tuebingen.de>
Web: http://www.tat.physik.uni-tuebingen.de/~schnette/
My email is as private as my paper mail. I therefore support encrypting
and signing email messages. Get my PGP key from www.keyserver.net.