Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!uwm.edu!rpi!uupsi!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.misc Subject: Re: CHALLENGE: heterogeneous collections Message-ID: <24673:Mar2802:15:1091@kramden.acf.nyu.edu> Date: 28 Mar 91 02:15:10 GMT References: <48805@nigel.ee.udel.edu> <7689:Mar2623:28:5091@kramden.acf.nyu.edu> <1991Mar27.164605.24547@visix.com> Organization: IR Lines: 22 In article <1991Mar27.164605.24547@visix.com> adam@visix.com writes: > Let me get this straight. To construct a heterogeneous list of M > items each guaranteeing N operations, I need to waste space for M*N > function pointers? No, because you can just have a single ``class'' structure with the N function pointers, and keep just one pointer per ``object.'' But this extra layer is pointless for small problems, and I didn't bother putting it in. > And I need to write an explicit constructor for every kind of list? That depends on what you mean by ``explicit.'' If you have several types each supporting some sort of redraw operation, and you want to set up a list of redrawable things, then you do have to say the correspondence between ``redrawable'' and the redrawing for each type. Other posters have mentioned how in object-oriented languages you can make the redrawing class either a superclass or a subclass of all the classes in question; either way provides the necessary correspondence, but I wouldn't say it's explicit. ---Dan