Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!eos!ames!elroy!orion.cf.uci.edu!uci-ics!ics.uci.edu!milne From: milne@ics.uci.edu (Alastair Milne) Newsgroups: comp.lang.pascal Subject: Re: function return value Message-ID: <8910@paris.ics.uci.edu> Date: 10 Mar 89 02:40:48 GMT References: <18581@adm.BRL.MIL> Sender: news@paris.ics.uci.edu Reply-To: Alastair Milne Distribution: usa Organization: Educational Technology Center, Dept. of ICS, UC Irvine Lines: 35 To: MATHRICH@umcvmb.missouri.edu MATHRICH@umcvmb.missouri.edu (Rich Winkel UMC Math Department) writes: >function what(var where:string):string; >begin > what:=where; > what:=what+what; (* string concatenation *) >end; >I'd actually like to reference the function return buffer (on the stack) > as a variable. >I tried something like: >var alias:string absolute what; >in an attempt to reference the buffer, but TP 5 acts like it wants the 'what' >to be an actual function call Turbo Pascal has never been very clever in its error diagnoses. It seems to be a little better now than it was in versions 2 or 3, but not much. Referring to the actual address of the function (which you could do with ADDR( What) ) is most unlikely to get you anywhere -- it's bound to be the address of the code in memory, and not of the function result. In fact, Turbo used to use AX to hold the result, and the means of getting to that are a) probably more trouble than convenience, and it's convenience you're after, and b) unreliable, since you can't be sure what's using AX at the time you reference it. You mention the stack. Are you sure TP5 uses the stack for function results? There are Pascals that do, but I doubt if Turbo is among them. Previous versions have not. I have seen at least one Pascal with a function-like construct like "VALUE()", which always returned the function's present value, rather than assuming a recursive call. As far as I know, though, this is not standard at all. Alastair Milne