home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / alt / amateur / 393 next >
Encoding:
Internet Message Format  |  1992-12-21  |  2.4 KB

  1. Xref: sparky alt.amateur-comp:393 comp.lang.c:18736 comp.lang.c++:18271 comp.misc:4668
  2. Newsgroups: alt.amateur-comp,comp.lang.c,comp.lang.c++,comp.misc
  3. Path: sparky!uunet!spool.mu.edu!sdd.hp.com!swrinde!network.ucsd.edu!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  4. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  5. Subject: Re: What is Object Oriented Programming? Is C doomed?
  6. Message-ID: <1992Dec21.101242.14848@ucc.su.OZ.AU>
  7. Sender: news@ucc.su.OZ.AU
  8. Nntp-Posting-Host: extro.ucc.su.oz.au
  9. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  10. References: <1992Dec16.145444.2130@nastar.uucp> <KANZE.92Dec17200928@slsvdnt.us-es.sel.de> <1992Dec18.154711.11632@nastar.uucp>
  11. Date: Mon, 21 Dec 1992 10:12:42 GMT
  12. Lines: 43
  13.  
  14. In article <1992Dec18.154711.11632@nastar.uucp> phardie@nastar.uucp (Pete Hardie) writes:
  15. >>> #define Push(list,element) AddElementToEnd(list,element)
  16. >>> #define Pop(list) RemoveElementFromEnd(list)
  17. >>
  18. >>Don't do this.
  19.  
  20. >> []
  21.  
  22. >>This will prevent you from accidently pushing something into a Queue,
  23. >>or enqueuing something on a stack.
  24. >
  25. >This is what I get for re-typing off-the-cuff instead of looking at my code.
  26. >
  27. >I left out that I have type-checking at runtime - the stack modules check
  28. >that the type of the container and report an error if it does not match
  29. >the expected type - thus no Push onto a Queue is possible.
  30. >
  31.  
  32.     Thats even WORSE! Give up doing things at run time
  33. that can and should be done at compile time.
  34. >
  35. >>Again, if this is done by derivation, fine.  Although I think
  36. >>implementing a general array class is probably simple enough to go for
  37. >>right off.  (The difference in access times for random access into a
  38. >>large array will very quickly become noticeable.)
  39.  
  40.     Not if you provide a suitable cache. This works pretty well
  41. if you need to insert and delete slots.
  42. >
  43. >If all I need is a well-bounded size array, I'll just use the
  44. >language's array type.
  45. >
  46.     No, dont do that either, C/C++ does not *have* an array type.
  47. Unless you crave super efficiency,
  48. a proper array template class is usually recommended. One that at
  49. least allows you to ask the length of the array, even if you
  50. dont actually bounds check accesses.
  51.  
  52. -- 
  53. ;----------------------------------------------------------------------
  54.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  55.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  56. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  57.