From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10294 invoked by alias); 29 Dec 2002 12:28:56 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 10226 invoked from network); 29 Dec 2002 12:27:42 -0000 Received: from unknown (HELO mailout03.sul.t-online.com) (194.25.134.81) by 209.249.29.67 with SMTP; 29 Dec 2002 12:27:42 -0000 Received: from fwd05.sul.t-online.de by mailout03.sul.t-online.com with smtp id 18ScXS-0003Md-08; Sun, 29 Dec 2002 13:27:30 +0100 Received: from because (520017001187-0001@[80.131.84.107]) by fmrl05.sul.t-online.com with esmtp id 18ScXK-0IkLjMC; Sun, 29 Dec 2002 13:27:22 +0100 Content-Type: text/plain; charset="us-ascii" From: Erik Schnetter To: gcc@gcc.gnu.org Subject: Re: c++ "with" keyword Date: Sun, 29 Dec 2002 06:49:00 -0000 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200212291327.33106.schnetter@uni-tuebingen.de> X-Sender: 520017001187-0001@t-dialin.net X-SW-Source: 2002-12/txt/msg01531.txt.bz2 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 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.