[DGD]returning copy() of arrays, objects

Stephen Schmidt schmidsj at union.edu
Mon Jan 31 04:54:31 CET 2000


On Mon, 31 Jan 2000, Neil McBride wrote:
[ quoting out of sequence ]
> Is the person who wrote Melville subscribed? Maybe they can explain =)

I am subscribed: whether I can explain remains to be seen :)
It's been a few years.

> Frantisek Fuka wrote:
> > While studying Melville Mudlib I found out that the functions which
> > return objects, arrays or mappings return "copy (result)" instead of
> > just "result", where copy() is defined in auto.c as:

There's been considerable discussion of this, all of which has
been pretty much on point: the idea is that you may want to pass
a mapping with some security implications. Typically, as best
I recall, the case is usually a query function along the lines
of object A, not secure, doing B->query_some_mapping() where
B contains secure data. B is willing to provide the information
but is not willing to let A modify it. So you duplicate the
value in memory. A can modify its copy all it wants to, but
B's internal data will not be changed.

I have a memory that arrays -do- require this kind of security
but would not swear to it. It is also possible that it used to
be necessary in earlier versions of DGD but isn't anymore, as
Melville is now about five or six years old. I don't recall
any such changes to DGD, but then, I probably wouldn't. 
 
> Perhaps whoever wrote that code thought the behaviour was as I
> described, or perhaps they were just having problems and the above code
> worked past it.

The former.

Kris Van Hees is entirely correct that the copy() function in
Melville will not correctly handle recursive structures - maps
containing mappings as elements, or arrays containing arrays
as elements. There are three reasons for that. First, Melville
doesn't have any such objects. Second, the goal of Melville is
to provide a simple, easily understood and easily modified
mudlib for novice mudlib hackers - I never added complicated
structures that weren't necessary, and to a novice, anything
recursive is complicated. Third, as Kris points out, making
it recursive is trivial, and anyone who wants to add that
modification can do so without too much trouble.

I hope the documentation of the Melville mudlib notes this
problem; I certainly intended that it would, but it might
possibly have escaped my attention when tidying up the code
for release. 


Stephen Schmidt

It is vain to expect a well-balanced government without a
well-balanced society.
			-- Gideon Welles





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



More information about the DGD mailing list