Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!mcvax!kth!draken!d88-eli From: d88-eli@nada.kth.se (Erik Liljencrantz) Newsgroups: comp.lang.pascal Subject: Re: complex numbers Message-ID: <1301@draken.nada.kth.se> Date: 14 Jul 89 12:22:56 GMT Reply-To: d88-eli@nada.kth.se (Erik Liljencrantz) Organization: Royal Institute of Technology, Stockholm, Sweden Lines: 39 Complex arithmetic can't be done the nice way (i.e. a:=b+c; and so on) in standard pascal. Suggestions of Pascal-SC, C++ and Ada has been posted, but what about Turbo Pascal 5.5. It's objectoriented (like C++) but is it possible to define addition (and the other operations as well) for objects? Or is it just possible to define objectspecific procedures and functions? If anybody missunderstood, things like this would be nice: VAR A,B,C:COMPLEX; { Our complex objecttype } ... A:=B+C; { Not + but complex + } ... A:=(B+C)/(B-C); { Very complex... } Procedures with VAR-parameters aren't that nice...: VAR A,B,C,Tmp1,Tmp2:COMPLEX; ... ComplexAdd(A,B,C); { Not that ugly, but wait... } ... ComplexAdd(Tmp1,B,C); { ...this is ugly! } ComplexSub(Tmp2,B,C); ComplexDiv(A,Tmp1,Tmp2); If functions could return our COMPLEX type then it could look like this: VAR A,B,C:COMPLEX; ... A:=ComplexAdd(B,C); ... A:=ComplexDiv(ComplexAdd(B,C),ComplexSub(B,C)); Soon my update to Turbo Pascal 5.5 is here and then I'll try to add my objects, but until then someone else might have done that... Erik Liljencrantz | "No silly quotes!" d88-eli@nada.kth.se | Embraquel Tuta