Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!pa.dec.com!src.dec.com!stolfi From: stolfi (Jorge Stolfi) Newsgroups: comp.lang.modula3 Subject: Re: Two Oberon questions Message-ID: <9104190753.AA03720@jumbo.pa.dec.com> Date: 19 Apr 91 07:53:10 GMT Lines: 42 In-Reply-To: Message of Thu, 18 Apr 1991 19:31:34 GMT from vsanchez@casbah.acns.nwu.edu (Victor Sanchez) <1991Apr18.193134.28552@casbah.acns.nwu.edu> To: m3 X-Folder-Carbon: lang-des [sakkinen] Can function procedures in Oberon return structured values? [vsanchez] ... if you have automatic garbage collection you can use the pointers to structures ... perhaps one pays a price for that, but returning structures is not very efficient anyway. Garbage collection and pointers can replace structured return values in some uses, but not all. It should cost only two or three instructions to return a two-word record as a procedure result. If you account for the cost of running the garbage collector, allocating that same record from the heap may well cost thousands of instructions---two or three orders of magnitude more. So, the pointer/heap solution is acceptable only in some cases: for low-intensity uses, for large structures, for values that will get copied many times, etc.. For many other uses (complex numbers, points, dates, etc.) structured return values will be a lot cheaper. Moreover, in languages like Modula-2 and Pascal, the use of heap records requires extra code: NEW calls, "^" operators, temporary variables. Structured return values are more natural and easier to use. Finally, allowing structured return values does not mean making the language more complex; on the contrary, it means removing a rather arbitrary rule... Jorge Stolfi DEC Systems Research Center, Palo Alto stolfi@src.dec.com ---------------------------------------------------------------------- DISCLAIMER: Don't blame me, I'm only a user.