places where sets are useful

J. Shapiro jss at sjuvax.UUCP
Tue Feb 26 17:14:27 AEST 1985


[Pacman's revenge...]

	It seems to me that in compiler writing, the case where one has
multiple transitions on a single input character is an ideal case for sets.
This is of course only an intermediate stage, so perhaps it does not
justify a full blown set type.

	A better example is one of modal software, where one's modes are
defined by a set of their names... For you pascalions:

type
	mymodes = (insert, error, append, ...);
var
	status = set of mymodes;

begin
...
if (status * [insert, append]) <> [] then begin....
...
end
...
end.

Is much more readable and therefore less likely to get mangled in software
rewrites then is the exhaustive "if" phrasing.


Jon Shapiro



More information about the Comp.lang.c mailing list