on1 construct

David W. Donald dwd at ccice6.UUCP
Fri Nov 9 09:52:12 AEST 1984


> One contruct that I've always wanted to have is:
> function ()
> {
>     on1  {
> 	bla, bla, bla...
>     };
>     etc...
> }

Try:

#define on1	static char x = 1; if (  x ? (--x,1) : 0 )
f()
{
	on1 {
		printf( "first time only\n" );
		printf( "even more\n" );
	}
	printf( "first and subsequent times\n" );
}

On a VAX with 4.2BSD I get unbeatable code with cc -O.

				Dave Donald



More information about the Comp.lang.c mailing list