Xref: utzoo comp.lang.c:17734 comp.lang.fortran:1950 Path: utzoo!dptcdc!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond!diamond From: diamond@diamond.csl.sony.junet (Norman Diamond) Newsgroups: comp.lang.c,comp.lang.fortran Subject: Re: fortran to C converter Message-ID: <10176@socslgw.csl.sony.JUNET> Date: 18 Apr 89 01:12:16 GMT References: <1989Apr14.161147.28053@utzoo.uucp> <12169@lanl.gov> Sender: news@csl.sony.JUNET Reply-To: diamond@csl.sony.junet (Norman Diamond) Followup-To: comp.lang.c Organization: Sony Computer Science Laboratory Lines: 40 In article <12169@lanl.gov> jlg@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@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?