on1 construct

Peter Lamb prl at murdu.OZ
Fri Nov 9 05:42:52 AEST 1984


[]
A nice way to put on1 in is to avoid the text of the on1 being part
of the macro. This involves a pretty grotty-looking if (with side-effects)
so if you want to keep pure, read no further:

#define on1	static int _not1_ = 0; if(!_not1_ && (_not1_ = 1))

then on1 has EXACTLY the same behavior as the if, except that it must be
the first statement unless the whole lot is covered by {}'s.

eg:
	on1	do_this();
	else	do_that();

or:
	on1 {
		blah, blech; blah;
	}

If you don't want the on1 code as the first `executable' statement then

	{
		on1	do_this();
		else	do_that();
	}

will get you out of trouble, albeit inelegantly.

	Peter Lamb,	......!decvax!mulga!prl
	University of Melbourne
	Parkville 3052
	Australia



More information about the Comp.lang.c mailing list