fortran to C converter

Norman Diamond diamond at diamond.csl.sony.junet
Tue Apr 18 11:12:16 AEST 1989


In article <12169 at lanl.gov> jlg at lanl.gov (Jim Giles) writes:

>(And, yes, I know Stroustrup recommends
>conversion here - he also implements COMPLEX as two DOUBLES (bad choice),
>and he only implements mixed mode operators fo COMPLEX*DOUBLE combinations.)

Perhaps the idiotic question should come first.  Why are two doubles a
bad choice?  If arbitrary-precision-rationals are available, then of
course a complex should be two arbitrary-precision-rationals (unless
that would also be a bad choice!...why); otherwise, what is wrong with
two doubles?

>The syntax I would recommend would allow declaration of
>ALL the mixed mode for a given operator in _one_ declaration:
>
>      Class ordinary_number:: (integer, float)
>
>      Commutative infix operator '*' is
>         Inline complex function mixed_mult (complex::x, ordinary_number::y)
>            mixed_mult.real = x.real * y
>            mixed_mult.imag = x.imag
>         end
>
>This syntax is Fortran-like (what about it for Fortran++ :-).

Looks Ada-like to me.  I only see one line there that a Fortran compiler
would be happy with.  Anyway, here's what's wrong with folding too many
declarations into one, with this kind of syntax:

Multiplication of complexes is commutative, but multiplication of
matrices is not.  Multiplication of complexes and multiplication of
matrices are both associative (which you forgot to mention).
Addition of complexes is commutative but addition of strings is not.
(Addition of strings, a popular feature in recent languages, should
have been multiplication instead, but that would be Not Invented Here.)

Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.jp at relay.cs.net)
  The above opinions are my own.   |  Why are programmers criticized for
  If they're also your opinions,   |  re-inventing the wheel, when car
  you're infringing my copyright.  |  manufacturers are praised for it?



More information about the Comp.lang.c mailing list