From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27272 invoked by alias); 29 Dec 2002 19:37:19 -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 27264 invoked from network); 29 Dec 2002 19:37:18 -0000 Received: from unknown (HELO windlord.stanford.edu) (171.64.13.23) by 209.249.29.67 with SMTP; 29 Dec 2002 19:37:18 -0000 Received: (qmail 19451 invoked by uid 50); 29 Dec 2002 19:37:07 -0000 To: Subject: Re: c++ "with" keyword References: <002c01c2af43$7a034720$fe78a8c0@SERVER> In-Reply-To: <002c01c2af43$7a034720$fe78a8c0@SERVER> ("Norman Jonas"'s message of "Sun, 29 Dec 2002 15:06:23 +0100") From: Russ Allbery Organization: The Eyrie Date: Sun, 29 Dec 2002 12:46:00 -0000 Message-ID: User-Agent: Gnus/5.090008 (Oort Gnus v0.08) XEmacs/21.4 (Honest Recruiter, sparc-sun-solaris2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-12/txt/msg01546.txt.bz2 Norman Jonas writes: > using the "with" keyword this code becomes much smaller and cleaner : > with ( verylongdescriptivename ) > { > .name = "hans"; > .street = "xxx 13"; > .city = "cologne"; > } > ( It is possible to use a pointer with a very short, undescriptive name, > but that makes the code unreadable and stupid ( variables should have > explanative names, not a confusing x* ) I must admit that I don't see the effective difference between: with (verylongdescriptivename) { .name = "hans"; .street = "xxx 13"; .city = "cologne"; } and { struct S& s = verylongdescriptivename; s.name = "hans"; s.street = "xxx 13"; s.city = "cologne"; } You say that variables should have long, explanative names, but the function of with is essentially to remove those names and rely on implicit context. That's exactly what using short variable names does. with is one of those constructs that renders code extremely difficult to understand if used for blocks of code longer than a few lines, because it complicates the way symbol lookups are performed (something that's already incredibly complex in C++). -- Russ Allbery (rra@stanford.edu)