|Complex Constants in Fortran firstname.lastname@example.org (1993-01-02)|
|Re: Complex Constants in Fortran email@example.com (1993-01-04)|
|Re: Complex Constants in Fortran firstname.lastname@example.org (1993-01-04)|
|From:||email@example.com (J. Giles)|
|Organization:||Los Alamos National Laboratory|
|Date:||Mon, 4 Jan 1993 19:31:59 GMT|
firstname.lastname@example.org (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).
Return to the
Search the comp.compilers archives again.