Article View: comp.lang.modula2
Article #2195Re: GENERIC TYPE IN MODULA-2
From: John Andrea
Date: Tue, 15 Dec 1992 15:15
Date: Tue, 15 Dec 1992 15:15
29 lines
1783 bytes
1783 bytes
I wrote >Unfortunately that approach removes type checking and you can put the wrong >data type into your tree. bevan replied >Not if you create a separate module where the parameters have the >correct type and must be coerced to the above. But how many types could you have that you would want to have in a tree. All the cards, ints, reals, chars, arrays of cards, arrays of chars, records with a card and a sting, records with a string and a real, records with two strings, ..... Quite a large variety, would you want to have a module for every type. bevan also replied >Granted you could get this wrong, but if you do it once, you can use >it as a template and then just use search/replace to create a new >module with the correct type. If the compiler is any good, it should >be able to inline all the interface procedures and so it doesn't cost >you anything at runtime. Templates. Yes thats the way i do it. I don't use generic tree modules like that as a pre-compiled library but i get the source code, make a part of the current project and compile it as part of the current project. Its less useful that a true library module, but it does allow for code reuse with no modifications so chances are that it works correctly. John Andrea
Technical Details
Message-ID:
<009651F2.BF850620.21331@esseX.stfx.ca>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!sdd.hp.com!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!ESSEX.STFX.CA!andreaShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!sdd.hp.com!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!ESSEX.STFX.CA!andrea From: andrea@ESSEX.STFX.CA (John Andrea) Newsgroups: comp.lang.modula2 Subject: Re: GENERIC TYPE IN MODULA-2 Message-ID: <009651F2.BF850620.21331@esseX.stfx.ca> Date: 15 Dec 92 15:15:45 GMT Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: Modula2 List <INFO-M2%UCF1VM.BITNET@uga.cc.uga.edu> Organization: The Internet Lines: 29