Article View: comp.std.c++
Article #1989Re: Pascal-like 'with' statement feasible in C++?
From: Kevin Lentin
Date: Mon, 18 Sep 1995 14:59
Date: Mon, 18 Sep 1995 14:59
33 lines
2057 bytes
2057 bytes
Eugene Radchenko (eugene@qsar.chem.msu.su) wrote: > type tpair = object > m,n: integer; > end; > var pairs : array[1..10] of tpair; > then you can write, for instance: > for i = 1 to 10 do > with pairs[i] do > m = n; > instead of > for i = 1 to 10 > pairs[i].m = pairs[i].n; > I think the first version is clearer and probably more easily optimizable > than the second. Would make 0 difference to optimisers, I suspect. The first may look shorter to you but it's still doing what the second one says. A compiler would be able to recognise this in both cases. 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. -- [==================================================================] [ Kevin Lentin |___/~\__/~\___/~~~~\__/~\__/~\_| ] [ kevinl@cs.monash.edu.au |___/~\/~\_____/~\______/~\/~\__| ] [ Macintrash: 'Just say NO!' |___/~\__/~\___/~~~~\____/~~\___| ] [==================================================================] [ 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:
<43k1g3$klh@engnews2.Eng.Sun.COM>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageReferences:
<MATT.95Sep14102849@physics10.Berkeley.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: kevinl@fangorn.cs.monash.edu.au (Kevin Lentin) Newsgroups: comp.std.c++ Subject: Re: Pascal-like 'with' statement feasible in C++? Date: 18 Sep 1995 14:59:15 GMT Organization: Monash University Approved: clamage@eng.sun.com (comp.std.c++) Distribution: world Message-ID: <43k1g3$klh@engnews2.Eng.Sun.COM> References: <MATT.95Sep14102849@physics10.Berkeley.EDU> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-User: kevinl X-Newsreader: TIN [UNIX 1.3 950823BETA PL0] X-Nntp-Posting-Host: fangorn.cs.monash.edu.au Content-Length: 1142 X-Lines: 29 Originator: clamage@taumet