Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site geowhiz.UUCP Path: utzoo!linus!decvax!genrad!mit-eddie!godot!harvard!seismo!uwvax!geowhiz!karsh From: karsh@geowhiz.UUCP (Bruce Karsh) Newsgroups: net.lang.c Subject: Re: on1 construct Message-ID: <151@geowhiz.UUCP> Date: Fri, 9-Nov-84 15:44:05 EST Article-I.D.: geowhiz.151 Posted: Fri Nov 9 15:44:05 1984 Date-Received: Sun, 11-Nov-84 20:01:29 EST References: <124@cadvax> Organization: UW Madison, Geology Dept. Lines: 37 > One contruct that I've always wanted to have is: > > function () > { > on1 { > bla, bla, bla... > }; > > etc... > } It's a little cryptic, but here is one way to do it: -- on1.c ------------- Cut Here ----------------------------------------- #define on1() static int notfirst= -1; if(!(++notfirst ? notfirst=1 : 0)) main() { sub(); sub(); sub(); } sub() { on1() printf("first time\n"); else printf("not first time\n"); } ---------------------- Cut Here ----------------------------------------- -- Bruce Karsh --------------------------- Univ. Wisconsin Dept. of Geology and Geophysics | | 1215 W Dayton, Madison, WI 53706 | THIS SPACE FOR RENT | (608) 262-1697 | | {ihnp4,seismo}!uwvax!geowhiz!karsh ---------------------------