Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site kuling.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!mcvax!enea!kuling!gostas From: gostas@kuling.UUCP (G|sta Simil{/ml) Newsgroups: net.lang.c Subject: Re: c types problem Message-ID: <874@kuling.UUCP> Date: Sat, 11-Jan-86 02:12:32 EST Article-I.D.: kuling.874 Posted: Sat Jan 11 02:12:32 1986 Date-Received: Wed, 15-Jan-86 01:30:23 EST References: <870@kuling.UUCP> <168@hadron.UUCP> <175@hadron.UUCP> Reply-To: gostas@kuling.UUCP (G|sta Simil{/ml) Organization: The Royal Inst. of Techn., Stockholm Lines: 43 In article <175@hadron.UUCP> jsdy@hadron.UUCP (Joseph S. D. Yao) writes: >In article <168@hadron.UUCP> jsdy@hadron.UUCP (Joseph S. D. Yao) writes: >>In article <870@kuling.UUCP> gostas@kuling.UUCP (G|sta Simil{/ml) writes: >>>The formal (but ugly) way to solve this would proparbly be to use a union >>>for all (about 10) types. But now I wonder if anyone have a simpler but >>>resonably portable solution? >> ... > >My original answer dealt with a union of outputs. Re-reading the >message, it seems that you are talking about a union of inputs. >Oh, well, the principle remains the same. > Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP} Yes, it's a union of inputs, no value will be returned and the calling program will have no idea what type the called functions are using currently, the code will look something like this: /* calling routine: */ typemix *base; /* malloc()'ed array, may change size during execution */ current_data = base; for (current_data = base; (something); current_data++, p++) if ((*p->function)(current_data)) /* value changed? */ (*p->action)(); /* really just a print routine */ /* called function: */ func(old_value) typemix *old_value; { some_type new_value = get_new_value(); if (new_value == old_value->some_type) return(0); old_value->some_type = new_value; return(1); } The example will be used when updating a screen, to avoid printing a field which have not changed value since the last update. G|sta Simil{ gostas@kuling.UUCP