home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 650 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.1 KB

  1. Path: cs.uwa.edu.au!jasonb
  2. From: jasonb@cs.uwa.edu.au (Jason S Birch)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: PPC compilers
  5. Date: 10 Jan 96 04:24:30 GMT
  6. Organization: The University of Western Australia
  7. Message-ID: <jasonb.821247870@cs.uwa.edu.au>
  8. References: <john.hendrikx.40ka@grafix.xs4all.nl> <MQAQx*XOe@yaps.rhein.de> <OWhVx*42f@yaps.rhein.de> <4cuhng$dmn@maureen.teleport.com>
  9. NNTP-Posting-Host: decadence.cs.uwa.oz.au
  10. X-Newsreader: NN version 6.5.0 #3 (NOV)
  11.  
  12. sschaem@teleport.com (Stephan Schaem) writes:
  13. >Arno Eigenwillig (arno@yaps.rhein.de) wrote:
  14. >: Why don't you read what he wrote? A reasonable example for that would
  15. >: be operations on clock_t.
  16.  
  17. > The claim was general: you can forget your variable type when you use 
  18. > them in C... I'm just saying thats its not wise.
  19.  
  20. What we've been (repeatedly) trying to say, is that's *not* what he
  21. said. He said you can forget about the *implementation* of your
  22. variable type on a particular machine (if the data is encapsulated
  23. correctly). The whole point being that in assembler, you cannot forget
  24. the implementation, because pratically every time you do *use* a
  25. "variable" of that type, you have to specify how big it is.
  26.  
  27. >: Why don't you read what he wrote? You use clock_t and treat it as a
  28. >: 'black box'. As you never name the underlying type, you are fully
  29. >: portable.
  30.  
  31. > What if clock_t is on other system a pointer to a bcpl string?
  32.  
  33. Unfortunately that will not work, because clock_t isn't sufficiently
  34. encapsulated - ie. to find the difference between two clock_t values,
  35. you must use "-", and "-" acts as expected only on ordinal types. With
  36. C++, however, "-" can be overloaded to work with *any* definition of
  37. clock_t, including BCPL strings.
  38.  
  39. For a better example, look at time_t. It comes with a full suite of
  40. support functions that effectively hide its implementation from you.
  41. So it could well be implemented as a BCPL string right now without
  42. causing any problems (at least for programmers who don't see it's eg.
  43. a long and try to use "-" to find differences in time instead of
  44. difftime()).
  45.  
  46. >: Name an existing assembler that allows such things.
  47.  
  48. > You can write yourself a simple preprocessor that will do a search replace
  49. > using a mytype.typedef file... The point I wanted to make is this:
  50. > [Store    variable of type A, into variable of type A]
  51. > This is what I think when I write
  52. > chipreg->bltcon0 = con0;
  53. > [Store con0 of type CHIPREG, into chipreg.bltcon0 of type CHIPREG]
  54. > &
  55. > move.w    (GLOBAL_con0_w,a4),(CHIPREG_bltcon0_w,a1)
  56. > [Store con0 of type WORD, into chipreg.bltcon0 of type WORD]
  57. > here I just happen to know WORD is 2 byte.. but so what.
  58.  
  59. Again, the "so what" is that in assembler, you're using the knowledge
  60. that CHIPREG is a WORD - as soon as you do that, you've tied yourself
  61. to only one implementation of CHIPREG.
  62.  
  63. > Stephan
  64.  
  65. -- 
  66. Jason S Birch                        ,-_|\ email: jasonb@cs.uwa.edu.au
  67. Department of Computer Science      /     \ Tel (work): +61 9 380 1840
  68. The University of Western Australia *_.-._/ Fax (work): +61 9 380 1089
  69. Nedlands  W. Australia  6907             v  Tel (home): +61 9 386 8630
  70.