🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1978

Re: Pascal-like 'with' statement feasible in C++?

#1978
From: Larry Hunter
Date: Sat, 16 Sep 1995 08:23
27 lines
1262 bytes
In article <MATT.95Sep14102849@physics10.Berkeley.EDU>, "Eugene Radchenko" <eugene@qsar.chem.msu.su> says:
>whether it is possible/worthwhile to introduce the analog of Pascal 'with'
>statement into C++ ? has someone proposed/considered it?

>  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;

You can use a reference in a block to get the same effect:

for (i=1;i<11;i++)
{pairs-element-type &X = pairs[i];
 X.m = X.n;
}

This uses features already in C++ and does not depend on an
implicit qualification by 'pairs[i].'.


---
[ 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.95Sep16002301@Austern>
Path: arc1-ca.pugleaf.net!howland.reston.ans.net!agate!agate!Matt
References: <MATT.95Sep14102849@physics10.Berkeley.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!howland.reston.ans.net!agate!agate!Matt
From: lhunter@acm.org (Larry Hunter)
Newsgroups: comp.std.c++
Subject: Re: Pascal-like 'with' statement feasible in C++?
Date: 16 Sep 1995 08:23:01 GMT
Organization: Sterling Information Group, Inc.
Approved: Matt@Austern
Message-ID: <MATT.95Sep16002301@Austern>
References: <MATT.95Sep14102849@physics10.Berkeley.EDU>
NNTP-Posting-Host: austern.hip.berkeley.edu