home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / compiler / 2080 < prev    next >
Encoding:
Text File  |  1993-01-04  |  2.0 KB  |  46 lines

  1. Newsgroups: comp.compilers
  2. Path: sparky!uunet!gatech!destroyer!gumby!yale!mintaka.lcs.mit.edu!spdcc!iecc!compilers-sender
  3. From: jlg@cochiti.lanl.gov (J. Giles)
  4. Subject: Re: Complex Constants in Fortran
  5. Reply-To: jlg@cochiti.lanl.gov (J. Giles)
  6. Organization: Los Alamos National Laboratory
  7. Date: Mon, 4 Jan 1993 19:31:59 GMT
  8. Approved: compilers@iecc.cambridge.ma.us
  9. Message-ID: <93-01-007@comp.compilers>
  10. References:  <93-01-003@comp.compilers>
  11. Keywords: Fortran, parse
  12. Sender: compilers-sender@iecc.cambridge.ma.us
  13. Lines: 31
  14.  
  15. uesu03@giac1.oscs.montana.edu (Lou Glassy) writes:
  16. | [in this construct] 
  17. |>    X = FU ( 1.0, 3.4 )     ! has to be a function call, but
  18. |>                            ! the scanner doesn't know that...
  19. | [should the scanner return (1.0,3.4) as a constant, or should it
  20. | instead return separate ( 1.0 , 3.4 ) tokens?]
  21.  
  22. The question addresses the distinction between a literal and a
  23. constructor.  A literal is a lexical token which is recognized by its form
  24. as a single data value.  A constructor is a syntactic form that builds
  25. data objects from simpler ones.  A complex constant in Fortran is usually
  26. treated as a constructor.  It is recognized as a parenthesized list
  27. containing two elements and not prefixed by an array or function name.  If
  28. Fortran had been designed with the intent to be extensible later to allow
  29. derived types (records, structs, whatever you prefer to call them), the
  30. design would probably have given the complex constructor a name:
  31.  
  32.       c = COMPLEX(1.2, 3.4)
  33.  
  34. instead of just a list syntax, since you can only have *one* type whose
  35. constructor is simply a list (though obviously quaternions could have a
  36. similar constructor with four elements, octonions with eight, etc.).
  37. Fortran was, alas, designed before such ideas were seriously contemplated
  38. for actual programming languages (though certainly the abstract idea of
  39. such derived types was probably present even then).
  40. -- 
  41. J. Giles
  42. -- 
  43. Send compilers articles to compilers@iecc.cambridge.ma.us or
  44. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  45.