home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / amiga / programm / 17952 < prev    next >
Encoding:
Text File  |  1992-12-30  |  2.1 KB  |  50 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!gatech!concert!samba!usenet
  3. From: Todd_Lewis@unc.edu (Todd M. Lewis)
  4. Subject: Re: AmigaDOS library functions and ANSI-C programming
  5. Message-ID: <1992Dec30.142028.10351@samba.oit.unc.edu>
  6. Sender: usenet@samba.oit.unc.edu
  7. Nntp-Posting-Host: guitar.oit.unc.edu
  8. Organization: UNC Office of Information Technology
  9. References: <1hrqupINNipe@aurora.unice.fr>
  10. Date: Wed, 30 Dec 1992 14:20:28 GMT
  11. Lines: 37
  12.  
  13. In article <1hrqupINNipe@aurora.unice.fr> beust@aurora.unice.fr (Cedric Beust)  
  14. writes:
  15. >
  16. >In article <1992Dec29.221144.26405@urbana.mcd.mot.com>,
  17. >qbarnes@urbana.mcd.mot.com (Quentin Barnes) writes:
  18. >>AmigaDOS functions which take pointers to objects when the objects
  19. >>aren't modified are not marked as "const". 
  20.  
  21. >I was reading the autodoc for AddHead which looks like
  22. >AddHead(struct List *list, struct Node *node)
  23. >and I was wondering if a copy of the node would be done and then
  24. >pointed to in the list or if *my* node would be directly referenced.
  25.  
  26. In this case, your node will be directly referenced and both
  27. *List and *node will be modified, so they should not be
  28. marked as "const".  It never occurred to me that AddHead() might
  29. not use my node directly.  
  30.  
  31. >The advantage of this method? Simple : you can use the same
  32. >static node to create a list.
  33.  
  34. The disadvantage?  Lots of overhead for a feature you almost never
  35. need or want.  In the rare case when you do, make the copies yourself
  36. before you call AddHead().
  37.  
  38. >Since this wasn't mentioned in the autodoc,
  39. >I decided to go safe and allocate myself a new node at each call.
  40. >The information might be in the RKM (I didn't check), but I really
  41. >think this kind of detail should be mentioned, either in natural
  42. >language, or by the use of the const keyword whenever possible.
  43.  
  44. In this case the const keyword would be dead wrong.  However, it
  45. would be better if const were used where appropriate.
  46. --
  47.  _/_/_/  _/     Todd_Lewis@unc.edu          You can lead a horse to 
  48.   _/    _/     utoddl@guitar.oit.unc.edu   Mohammad, but you can't make
  49.  _/    _/_/_/                             a mountain drink a mole hill.
  50.