Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utcs!mnetor!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP Newsgroups: net.lang,net.lang.c Subject: Re: WITH statement Message-ID: <2366@umcp-cs.UUCP> Date: Sat, 12-Jul-86 02:20:19 EDT Article-I.D.: umcp-cs.2366 Posted: Sat Jul 12 02:20:19 1986 Date-Received: Sat, 12-Jul-86 07:21:43 EDT References: <1003@zog.cs.cmu.edu> Reply-To: chris@maryland.UUCP (Chris Torek) Followup-To: net.lang Organization: University of Maryland, Dept. of Computer Sci. Lines: 58 Xref: utcs net.lang:2514 net.lang.c:9677 In article <1003@zog.cs.cmu.edu> dlc@zog.cs.cmu.edu (Daryl Clevenger) writes: > I dislike Pascal as much as the next C hacker, but one feature >that could be useful to add to C is something akin to the Pascal >"WITH" statement. ... By using such a construct, one avoids long >statements when using deeply nested structures/unions or the kludgy >method of using defines. I never did like `with'. I would like it a lot more if . . . well, let me see if I can construct a good bad example first. type x = record ... end; y = record ... end; z = record ... end; var foo : x; zarog : y; prullo : z; { several hundred pages of code } with foo, zarog, prullo do begin ... { next three statments use fields } snert := 5 * bazzi; bibble := 10; roj := klewp mod snert; ... end; ... To which variables do those fields refer? If `with' is intended as shorthand, I would like to see it used in more this way: with a = foo, b = zarog, c = prullo do begin ... b.snert = 5 * a.bazzi; c.bibble := 10; a.roj := c.klewp mod b.snert; Note that this allows member name `collisions' to be disambiguated: b.snert = 5 * a.bazzi; c.bibble := 10; a.roj = c.klewp mod a.snert; ---if that is in fact what is meant. (I have a feeling that `WITH' originally meant `Listen, compiler, put a pointer to this here record into a machine register now, because I am about to use it a whole bunch.') -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu