home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / modula2 / 1570 < prev    next >
Encoding:
Internet Message Format  |  1992-12-15  |  1.7 KB

  1. Path: 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
  2. From: andrea@ESSEX.STFX.CA (John Andrea)
  3. Newsgroups: comp.lang.modula2
  4. Subject: Re: GENERIC TYPE IN MODULA-2
  5. Message-ID: <009651F2.BF850620.21331@esseX.stfx.ca>
  6. Date: 15 Dec 92 15:15:45 GMT
  7. Sender: usenet@ucbvax.BERKELEY.EDU
  8. Reply-To: Modula2 List <INFO-M2%UCF1VM.BITNET@uga.cc.uga.edu>
  9. Organization: The Internet
  10. Lines: 29
  11.  
  12.  
  13.   I wrote
  14.   >Unfortunately that approach removes type checking and you can put the wrong
  15.   >data type into your tree.
  16.  
  17.   bevan replied
  18.   >Not if you create a separate module where the parameters have the
  19.   >correct type and must be coerced to the above.
  20.  
  21. But how many types could you have that you would want to have in a tree.
  22. All the cards, ints, reals, chars, arrays of cards, arrays of chars,
  23. records with a card and a sting, records with a string and a real, records
  24. with two strings, ..... Quite a large variety, would you want to have a
  25. module for every type.
  26.  
  27.   bevan also replied
  28.   >Granted you could get this wrong, but if you do it once, you can use
  29.   >it as a template and then just use search/replace to create a new
  30.   >module with the correct type.  If the compiler is any good, it should
  31.   >be able to inline all the interface procedures and so it doesn't cost
  32.   >you anything at runtime.
  33.  
  34. Templates. Yes thats the way i do it. I don't use generic tree modules like
  35. that as a pre-compiled library but i get the source code, make a part of the
  36. current project and compile it as part of the current project.
  37.   Its less useful that a true library module, but it does allow for code
  38. reuse with no modifications so chances are that it works correctly.
  39.  
  40. John Andrea
  41.