home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / amiga / programm / 13395 < prev    next >
Encoding:
Text File  |  1992-09-15  |  3.6 KB  |  82 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!mcsun!sunic!liuida!micja
  3. From: micja@ida.liu.se (Michael Jansson)
  4. Subject: Re: What is (APTR) ?
  5. Message-ID: <1992Sep15.141758.1228@ida.liu.se>
  6. Originator: micja@obel30
  7. Sender: news@ida.liu.se
  8. Organization: Department of Computer Science, University of Linkoping
  9. References: <9209140718.AA09878@teetot.acusd.edu> <copes.716466012@marsh> <1630@lysator.liu.se> <1992Sep14.130914.13505@ida.liu.se> <1641@lysator.liu.se>
  10. Date: Tue, 15 Sep 1992 14:17:58 GMT
  11. Lines: 69
  12.  
  13.  
  14. In article <1641@lysator.liu.se>, boberg@lysator.liu.se (Stefan Boberg) writes:
  15. > micja@ida.liu.se (Michael Jansson) writes:
  16. > > boberg@lysator.liu.se (Stefan Boberg) writes:
  17. > >>   Excerpt from `exec/types.h' :
  18. > >> 
  19. > >>   /*  WARNING: APTR was redefined for the V36 Includes!  APTR is a   */
  20. > >>  /*  32-Bit Absolute Memory Pointer.  C pointer math will not       */
  21. > >> /*  operate on APTR --  use "ULONG *" instead.                     */
  22. > >>                             ^^^^^^^^^
  23. > >> 
  24. > >>   BTW: Why isn't this "UBYTE *" ?? Why on earth would anyone want ULONG
  25. > >> pointer arithmetic?
  26. > >Have you ever used Tags? Process a file like Font:CGTimes.otag and you will
  27. > >find several reasons for doing pointer maths (trust me) on ULONG:s.
  28. >   Sure, but when working with tags you work with TagItem structures and
  29. > the corresponding utility.library functions to obtain the taglist entries.
  30. > You should never directly address a TagItem list by doing pointer
  31. > arithmetic on the taglist pointer.
  32.  
  33. Yes, this is typically true (and it should be). There are exceptions however,
  34. such as when processing the OT_Indirect bit flag in diskfont tag files. This does
  35. not have anything to do with APTR's though - it simple illustrates that you do
  36. need to long word pointer arithmetics some times. More typical examples are when
  37. you have to do long word aligned pointer arithmetic.
  38.  
  39. >   My point was that since 680x0 memory is built up from bytes, the
  40. > most natural pointer type would be `char *' (or UBYTE *, to use CBM 
  41. > terminology).
  42.  
  43. Well, the Motorola 68k family does actually recognise data as bits, *then* bytes,
  44. words and long words.  So the "natural" pointer type would be to bits then,
  45. right!? :-).
  46.  
  47. All jokes aside - An APTR is a pointer to a *typeless* memory chunk. You can not
  48. assume that the referred memory will be accessed as bytes or long words. It
  49. *must* follow the alignment rules that are the most restrictive, i.e. be long
  50. word aligned! Use STRPTR or whatever if you want to point out data of some known
  51. type.
  52.  
  53. >   Anyway, I really don't care since I never use the types defined in 
  54. > <exec/types.h> ...
  55.  
  56. Then consider the use of (void *) and (char *). The first is a generic pointer
  57. which can point to data of any type, the latter can only point out bytes. They
  58. can not be used interchangeably.
  59.  
  60. APTR`s (or void *) are extremely useful when applying software engineering
  61. techniques such as "data hiding" and "polymorphism", where a pointer may referred
  62. to data of an unknown type.
  63.  
  64. > >     Michael Jansson      mij@IDA.LIU.SE, uunet!liuida!mij, mij@SELIUI51.BITNET
  65. > --
  66. > Stefan Boberg - AP & EE student at Linkoping Institute of Technology, Sweden
  67. >  Author of LhA, ArjA and LhArcA. Co-author of Alien Breed, Project X, Full
  68. >   Contact and Miami Chase.
  69. >     EMail: boberg@lysator.liu.se, lha@augs.se       FidoNet: 2:204/404
  70.  
  71. PS: Are you planning of going to the K|ln fair (9-11 Oct)? We (Toolbox) might be
  72. able to arrange transport.
  73. -- 
  74.      __________________________________________________________________________
  75.      Michael Jansson      mij@IDA.LIU.SE, uunet!liuida!mij, mij@SELIUI51.BITNET
  76.