Pascal to C (and vice versa)

Chris Torek chris at mimsy.umd.edu
Wed Oct 25 02:20:47 AEST 1989


In article <20355 at mimsy.umd.edu> I wrote:
[regarding
>>	  X := X * ['b','c'];
where `X' is a `set of char']

>		SETINTERSECT(X, 256, 'b'), SETINTERSECT(X, 256, 'c');
>which (as you can see) is not very nice.

Oops.  It is also not very right.  Set intersection done the hard way
requires a temporary set.  Since this is a constant intersection, a
Pascal-to-C translator could rewrite it as

	X[0] = X[1] = X[2] = X[3] = X[4] = X[5] = X[6] = X[7] =
	X[8] = X[9] = X[10] = X[11] = X[13] = X[14] = X[15] = 0,
	X[12] &= (2|4);

(assuming ASCII characters).  More likely, it would create a local
variable containing another 256-bit set, clear it all, set bits for 'b'
and 'c', and then call a set-intersection macro.
-- 
`They were supposed to be green.'
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list