WITH statement

chris at umcp-cs.UUCP chris at umcp-cs.UUCP
Sat Jul 12 16:20:19 AEST 1986


In article <1003 at zog.cs.cmu.edu> dlc at 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 at umcp-cs		ARPA:	chris at mimsy.umd.edu



More information about the Comp.lang.c mailing list