public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Erik Schnetter <schnetter@uni-tuebingen.de>
To: gcc@gcc.gnu.org
Subject: Re: c++ "with" keyword
Date: Sun, 29 Dec 2002 06:49:00 -0000	[thread overview]
Message-ID: <200212291327.33106.schnetter@uni-tuebingen.de> (raw)

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.

             reply	other threads:[~2002-12-29 12:28 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-29  6:49 Erik Schnetter [this message]
2002-12-29  8:32 Norman Jonas
2002-12-29 12:46 ` Russ Allbery
2003-01-04 14:29 Robert Dewar
2003-01-04 15:00 ` Momchil Velikov
2003-01-04 15:24   ` Andrew Haley
2003-01-04 16:25     ` Neil Booth
2003-01-04 17:35     ` Gianni Mariani
2003-01-04 17:59       ` Tolga Dalman
2003-01-04 18:36         ` Gianni Mariani
2003-01-04 18:54           ` Tolga Dalman
2003-01-04 23:32         ` Kevin Handy
2003-01-04 17:06 Robert Dewar
2003-01-04 17:22 ` Daniel Berlin
2003-01-05 11:33 ` Andrew Haley
2003-01-05 11:36   ` Toon Moene
2003-01-04 17:52 Robert Dewar
2003-01-04 17:59 ` Gianni Mariani
2003-01-04 18:11 Robert Dewar
2003-01-04 18:47 ` Gianni Mariani
2003-01-04 19:13 Robert Dewar
2003-01-04 20:58 ` Gianni Mariani
2003-01-04 19:36 Robert Dewar
2003-01-04 19:59 ` Tolga Dalman
2003-01-04 20:09 Robert Dewar
2003-01-04 20:59 Robert Dewar
2003-01-04 22:36 ` Gianni Mariani
2003-01-04 22:13 Robert Dewar
2003-01-04 23:27 Robert Dewar
2003-01-04 23:36 ` Lynn Winebarger
2003-01-05  2:55 ` Gianni Mariani
2003-01-05  0:29 Robert Dewar
2003-01-05  0:37 ` Kevin Handy
2003-01-05  0:38 Robert Dewar
2003-01-05  3:16 Robert Dewar
2003-01-05 12:44 Robert Dewar
2003-01-05 12:56 Robert Dewar
2003-01-05 18:22 ` Joseph S. Myers
2003-01-05 12:56 Robert Dewar
2003-01-06 12:18 ` Andrew Haley
2003-01-05 13:03 Robert Dewar
2003-01-05 13:39 ` Toon Moene
2003-01-05 18:41 Robert Dewar
2003-01-06 13:07 Robert Dewar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200212291327.33106.schnetter@uni-tuebingen.de \
    --to=schnetter@uni-tuebingen.de \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).