home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / fortran / 3331 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  3.7 KB

  1. Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!purdue!mentor.cc.purdue.edu!pop.stat.purdue.edu!hrubin
  2. From: hrubin@pop.stat.purdue.edu (Herman Rubin)
  3. Newsgroups: comp.lang.fortran
  4. Subject: Re: Scientists as Programmers (was Re: Smal
  5. Message-ID: <BtwK17.ADM@mentor.cc.purdue.edu>
  6. Date: 1 Sep 92 13:55:54 GMT
  7. References: <1992Aug30.232409.15262@nrao.edu> <1992Aug31.163405.2169@newshost.lanl.gov> <1992Aug31.164354.3518@newshost.lanl.gov>
  8. Sender: news@mentor.cc.purdue.edu (USENET News)
  9. Organization: Purdue University Statistics Department
  10. Lines: 66
  11.  
  12. In article <1992Aug31.164354.3518@newshost.lanl.gov> jlg@cochiti.lanl.gov (Jim Giles) writes:
  13. >In article <1992Aug30.232409.15262@nrao.edu>, cflatter@nrao.edu (Chris Flatters) writes:
  14.  
  15.             ..................
  16.  
  17. <|> It is rarely necessary to violate type constraints in a strongly typed language.
  18. <|> When it is necessary it is possible to localize the code that does this.  Most
  19. <|> typesafe languages provide mechanisms to avoid the constraints of the type
  20. <|> system in these rare cases (eg. the WORD data type in Modula 2).
  21.  
  22. >The definition of the term `strongly typed' is that the types of all
  23. >expressions are known to the compiler at compile time (it would be
  24. >preferable if that were called static typing, but that's now used to
  25. >mean that the data is statically *allocated* - oh well).  It is, however,
  26. >*often* useful to be able to violate type constraints (if you know what
  27. >you're doing - it's always a machine/system dependent thing to do).
  28.  
  29. >No one is recommending (and Herman didn't) that strict typing be abandoned.
  30. >It is possible to have type coercion and *still* be able to statically
  31. >determine type.  For example, the following declaration might be introduced
  32. >(in no particular language):
  33.  
  34. >      float :: x(500)
  35. >      type float_internal is
  36. >         bit.1  :: sign
  37. >         bit.8  :: exponent
  38. >         bit.23 :: significand
  39. >      end type float_internal
  40. >      map x as float_internal    ! overlay the structure of floats on the array
  41. >      ...
  42. >      x.sign(1) = x.sign(1)+1    ! change the sign of x(1)
  43. >      x.exponent(5) = x.exponent(5)+1    ! multiply x(5) by 2
  44.  
  45. I did mean that the user should be able, when appropriate, to completely 
  46. ignore the type.  This should be a deliberate act, however, by one who
  47. knows what is being done.
  48.  
  49. The above example shows some of the problems.  The multiplication above
  50. will work provided there is no overflow and x(5) != 0.  If the leading
  51. bit of normalized numbers is present, it will also work if x(5) = 0, but
  52. dividing by 2 by subtracting one from the exponent will not work.
  53.  
  54. Exponent arithmetic is slightly different than expected, and some machines
  55. have a hardware instruction to do it.  It is necessary to be careful.
  56.  
  57. >This is much better than some anonymous `word' type.  Notice that 
  58. >everything used above is strongly typed.  The notion of `bit.n' as 
  59. >being n-bit unsigned integers was used, as well as the notion that 
  60. >a structure or record of such things is *packed* and remains in 
  61. >the order declared.  The only thing machine dependent is the map
  62. >itself: otherwise the struct, or its components, behave exactly 
  63. >as any other objects of their respective declared types.
  64.  
  65. <|> [...]
  66. <|> Restrictions on the introduction of new operators arise from practical
  67. <|> considerations.  The introduction of a new infix operator changes the
  68. <|> syntax of the language significantly.
  69.  
  70. >Well, it depends on how your syntax is specified and processed.  Haskell
  71. >allows just about anything to be used as an operator and yet never has
  72. >its syntax changed by user definitions.
  73. -- 
  74. Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907-1399
  75. Phone: (317)494-6054
  76. hrubin@pop.stat.purdue.edu (Internet, bitnet)  
  77. {purdue,pur-ee}!pop.stat!hrubin(UUCP)
  78.