[DGD] arrays returned from fuctions

Stephen Schmidt schmidsj at union.edu
Wed Oct 10 15:05:52 CEST 2001


On Wed, 10 Oct 2001 pete at ana.sk wrote:
> It looks like arrays returned from functions are returned by
> reference, when i modify returned value it modifies original array
> too. Is that expected behaviour or a bug?

Expected behavior.

> And if its ok, how to return a copy of array?

You'll need a copy() function which takes an array and returns
a copy of it. Melville has one, although it doesn't handle
recursive arrays (arrays with elements that are arrays)
though it could be reasonably easily extended to do that
(and one day it will). I'm sure the kernel lib has one
too, not that I could tell you where. Take a look at the
sources and see how it's done.

Steve


_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list