On Wed, Feb 26, 2003 at 04:09:37PM +0000, Angus Leeming wrote: > As John has noted, these differnet LFUNs are sufficiently similar to make > the thought of collapsing them together attractive. > > My question: should I use these switches or should I use if-blocks?
> case LFUN_INDEX_APPLY: > case LFUN_REF_APPLY: { > dispatch_result result = UNDISPATCHED; > > string name; > switch (ev.action) { > case LFUN_INDEX_APPLY: name = "index"; break; > case LFUN_REF_APPLY: name = "ref"; break; > default: break; > } What about a function string getNameOfTheBeast(whatever) { if (whatever == LFUN_INDEX_APPLY) return "index"; if (whatever == LFUN_REF_APPLY) return "ref"; } ? > switch (ev.action) { > case LFUN_INDEX_APPLY: > inset = new InsetIndex(params); > break; > case LFUN_REF_APPLY: > inset = new InsetRef(params, *buffer_); > break; > default: > break; > } This can't go to the factory? This is it's purpose after all... Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)