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