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