Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!iuvax!purdue!mentor.cc.purdue.edu!pur-ee!pur-phy!hal From: hal@pur-phy (Hal Chambers) Newsgroups: comp.lang.pascal Subject: Re: complex numbers Message-ID: <2360@pur-phy> Date: 14 Jul 89 11:40:25 GMT References: <2751@ohstpy.mps.ohio-state.edu> Reply-To: hal@newton.physics.purdue.edu.UUCP (Hal Chambers) Organization: Purdue Univ. Physics Dept., W. Lafayette, IN Lines: 34 In article <2751@ohstpy.mps.ohio-state.edu> heff@ohstpy.mps.ohio-state.edu writes: >. . . to write equations in source code such as > a =: b + c; > a := (b+c)/(d+e); >as can be done in fortran. For that matter, are there any languages beside >fortran which allow easy computation of complex numbers? This is allowed in Ada. Besides defining the type Complex, Ada allows programmers to define functions named "+", "/", etc. (and if I remember correctly, these functions can be defined as "INLINE" so that the code is generated in place). The compiler determines which "+" function to use from the types of the operands. To be complete, be sure to define the operators for mixed-mode expressions (complex + real, real + complex, etc.). Although Pascal (and Modula-2, etc.) allows the definition of a Complex type, there is no way for the programmer to define the operators other than as explicit procedure calls (functions can't return a structured type). So the examples above would appear as something like: > a =: b + c; cadd(a, b,c); > a := (b+c)/(d+e); cadd(c1, b,c); cadd(c2, d,e); cdiv(a, c1,c2); Ugly!!!! -- Hal Chambers hal@newton.physics.purdue.edu hal@physics-newton.arpa