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

  1. Path: nntp.teleport.com!sschaem
  2. From: sschaem@teleport.com (Stephan Schaem)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: PPC compilers
  5. Date: 10 Jan 1996 17:51:15 GMT
  6. Organization: Teleport - Portland's Public Access (503) 220-1016
  7. Message-ID: <4d0uaj$i4i@maureen.teleport.com>
  8. References: <john.hendrikx.40ka@grafix.xs4all.nl> <MQAQx*XOe@yaps.rhein.de> <OWhVx*42f@yaps.rhein.de> <4cuhng$dmn@maureen.teleport.com> <jasonb.821247870@cs.uwa.edu.au>
  9. NNTP-Posting-Host: julie.teleport.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Jason S Birch (jasonb@cs.uwa.edu.au) wrote:
  13. : sschaem@teleport.com (Stephan Schaem) writes:
  14. : >Arno Eigenwillig (arno@yaps.rhein.de) wrote:
  15. : >: Why don't you read what he wrote? A reasonable example for that would
  16. : >: be operations on clock_t.
  17.  
  18. : > The claim was general: you can forget your variable type when you use 
  19. : > them in C... I'm just saying thats its not wise.
  20.  
  21. : What we've been (repeatedly) trying to say, is that's *not* what he
  22. : said. He said you can forget about the *implementation* of your
  23. : variable type on a particular machine (if the data is encapsulated
  24. : correctly). The whole point being that in assembler, you cannot forget
  25. : the implementation, because pratically every time you do *use* a
  26. : "variable" of that type, you have to specify how big it is.
  27.  
  28.  Nope you specify its type... when I decalre my variable in ASM I choose
  29.  a type... char, word, long, float, double, pointer, ...
  30.  
  31.  I can tell you that in asm or C I dont care a bunch of the float format,
  32.  but I care about its range... When I have a routine with float and long
  33.  I keep track wich is wich otherwise I will write crap (In C or asm)
  34.  
  35.  This is why I think like I think when I write C or asm.
  36.  
  37. : >: Why don't you read what he wrote? You use clock_t and treat it as a
  38. : >: 'black box'. As you never name the underlying type, you are fully
  39. : >: portable.
  40.  
  41. : > What if clock_t is on other system a pointer to a bcpl string?
  42.  
  43. : Unfortunately that will not work, because clock_t isn't sufficiently
  44. : encapsulated - ie. to find the difference between two clock_t values,
  45. : you must use "-", and "-" acts as expected only on ordinal types. With
  46. : C++, however, "-" can be overloaded to work with *any* definition of
  47. : clock_t, including BCPL strings.
  48.  
  49.  Yes, but you cant put c++ to prove the point that 'C programmer' 
  50.  dont need to know there variable type, and there variable type
  51.  definition...
  52.  
  53. : For a better example, look at time_t. It comes with a full suite of
  54. : support functions that effectively hide its implementation from you.
  55. : So it could well be implemented as a BCPL string right now without
  56. : causing any problems (at least for programmers who don't see it's eg.
  57. : a long and try to use "-" to find differences in time instead of
  58. : difftime()).
  59.  
  60.  Yes... I do that in asm and C too... 
  61.  
  62. : >: Name an existing assembler that allows such things.
  63.  
  64. : > You can write yourself a simple preprocessor that will do a search replace
  65. : > using a mytype.typedef file... The point I wanted to make is this:
  66. : > [Store    variable of type A, into variable of type A]
  67. : > This is what I think when I write
  68. : > chipreg->bltcon0 = con0;
  69. : > [Store con0 of type CHIPREG, into chipreg.bltcon0 of type CHIPREG]
  70. : > &
  71. : > move.w    (GLOBAL_con0_w,a4),(CHIPREG_bltcon0_w,a1)
  72. : > [Store con0 of type WORD, into chipreg.bltcon0 of type WORD]
  73. : > here I just happen to know WORD is 2 byte.. but so what.
  74.  
  75. : Again, the "so what" is that in assembler, you're using the knowledge
  76. : that CHIPREG is a WORD - as soon as you do that, you've tied yourself
  77. : to only one implementation of CHIPREG.
  78.  
  79.  I never said that C typedef was bad and not an advantage over C? did I?
  80.  that was not was I was trying to say... I was trying to say that the
  81.  thinking process in C or asm here is the same.
  82.  
  83.  Now if I want to write
  84.  bltcon0 |= defaultbltcon0;  I better know what CHIPREG is about.
  85.  
  86.  Stephan
  87.