Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!gatech!udel!udccvax1!udccpyr1!mikej From: mikej@pyr1.acs.udel.EDU (Michael Jacobs) Newsgroups: comp.lang.pascal Subject: Re: function returning a record? Keywords: goofy types, functions Message-ID: <2994@udccvax1.acs.udel.EDU> Date: 3 Mar 89 20:39:00 GMT References: <2012@pur-phy> <790@rpi.edu> <2016@pur-phy> Sender: usenet@vax1.acs.udel.EDU Reply-To: mikej@pyr1.acs.udel.EDU (Michael Jacobs) Organization: University of Delaware Lines: 55 >>FUNCTION Complex_Add(z1,z2 : complex) : comples; > >Though I understand what you are getting at, a posting just previous >to yours points out that the function may not be anything other than >simple types and pointers. So what that means is that your solution Then declare Type Complex_Number = Record X, Y : Real End; Complex = ^Complex_Number; Procedure Complex_Allocate ( Var C : Complex ); Begin New ( C ) End; Function Complex_Add ( A, B : Complex ) : Complex; ---- Everytime you want to use a complex number, you'd have to create a record and pointer for it (using Complex_Allocate ( perhaps even use a FreeList algorithm for it ) ) and in Complex_Add, two already existing pointers at sent in (or some VERY serious barfing will take place) and a new third on is returned. Another procedure and two more functions will be needed: Procedure Load_Complex ( x,y : real; var C : Complex ); Function Real_Part ( C : Complex ) : Real; Function Imaginary_Part ( C : Complex ) : Real; OR! using your original implementation of the type Procedure Complex_Add ( A, B : Complex; Var C : Complex ); add 'em up and stick 'em in C. That should work. The first thing I talked about with the pointers and billions of functions and procedures is a lot more formal and will probably get more better grades in CIS theory/programming classes, more the second was is alot easier. Mike J, The Grey Sysop... | Ancient Spirits of Evil, transform this Temporal Hitchhiker | decayed form into Mumm-ra, the Ever Living! mikej@vax1.acs.udel.EDU |