Article View: comp.std.c++
Article #1999Re: Pascal-like 'with' statement feasible in C++?
From: Danny Bain
Date: Wed, 20 Sep 1995 23:32
Date: Wed, 20 Sep 1995 23:32
41 lines
1915 bytes
1915 bytes
On 20 Sep 95 18:43:00 GMT, shankar@engr.sgi.com (Shankar Unni) wrote:
>Kevin Lentin (kevinl@fangorn.cs.monash.edu.au) wrote:
>> With is purely a piece of syntactical sugar (with some ugly type problems
>> described elsewhere in this thread). It provides a way of making your life
>> easier (or different). Not the compiler.
>
>It is an evil piece of syntactic sugar. Wait till these "with"'s start
>getting nested, and have giant, 500+-line blocks inside them. Reading the
>resultant code is a *nightmare*.
Actually, the C++ draft includes a keyword 'using' that does what the
Pascal 'with' keyword does and many more things. Since C++ will have
the concept of 'namespace', the 'using' keyword allows one to switch a
block of code to use the names in another namespace.
The example given is as follows:
struct B
{
void f(char);
void g(char);
};
struct D : B
{
using B::f;
void f(int) { f('c'); } // calls B::f(char)
void g(int) { g('c'); } // recursively calls d::g(int)
}
This applies to member functions, variables, typedefs and any other
nested names declared or defined.
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<MATT.95Sep20163207@physics2.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!128.32.155.1!mattReferences:
<MATT.95Sep14102849@physics10.Berkeley.EDU> <43k1g3$klh@engnews2.Eng.Sun.COM> <43pn06$b2k@fido.asd.sgi.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!128.32.155.1!matt From: danny@computek.net (Danny Bain) Newsgroups: comp.std.c++ Subject: Re: Pascal-like 'with' statement feasible in C++? Date: 20 Sep 1995 23:32:07 GMT Organization: AltNet - $5/month uncensored news - http://www.alt.net Approved: matt@physics2.Berkeley.EDU (Matt Austern) Message-ID: <MATT.95Sep20163207@physics2.Berkeley.EDU> References: <MATT.95Sep14102849@physics10.Berkeley.EDU> <43k1g3$klh@engnews2.Eng.Sun.COM> <43pn06$b2k@fido.asd.sgi.com> Reply-To: danny.bain@pobox.com NNTP-Posting-Host: physics2.berkeley.edu