[DGD] copy() or lack thereof in Melville
M M
crashnbrn71 at yahoo.ca
Sun Jan 25 04:04:31 CET 2004
Well I'm new to the list (and how often is that heard)
and working(attempting to) on a new mud, but of course
:) I haven't worked with LP in quite some years, and
was wondering if perhaps some wisemen might have some
answers.
We are working with Melville. And I've seemed to come
across some discrepancies, or perhaps my lack of
understanding DGD.
in /system/auto/security.c - there is a function
called copy:
nomask mixed copy (mixed a) {
mixed b ;
if (typeof(a)==T_ARRAY || typeof(a)==T_MAPPING) {
b = a[..] ;
} else {
b = a ;
}
return b ;
}
which is used, according to the header, as a
non-recursive copy function for mappings, arrays and
other variables represented by pointers. It also
states, that if the variable itself contains pointers,
that they are _not_ copied.
Now in various files we will see this function finding
its way into the code, like users_d.c whenever a
map_indices() or map_values() is returned. or the
value for query_this_player() -> return
copy(this_player)
in /inherit/room.c we see it:
mapping query_exits() { return copy(exits); }
in /inherit/object.c:
object *query_inventory()) { return
copy(inventory)
Places we dont see it:
----------------------
in /system/users_d.c:
object find_user(string name) {
if (!users) users = ([ ]) ;
if (member_array(name,map_indices(users))==-1)
return 0 ;
return users[name] ;
}
which returns the user obj which is paired with name.
in /inherit/object.c:
string *query_id() { return id ; }
which returns an array of id names.
Now I tested, the query_id() function and easily got
the array of id's which I could output.
And I'm perfectly familiar with pointers in C, though
sometimes difficult to work with :)
So my question is, is the copy() function needed? is
it redundant now in dgd 1.2.7# ? since melville was
released back in dgd 1.0.# days? And if it's not
redundant, then shouldn't everything that returns a
mapping/array need it?
I guess I am confused about how pointers are working
in DGD/LPC, cuz if copy() is needed I don't get when I
should or shouldn't be using it.
Sorry for this long ramble, not sure how to be more
concise and still explain.
______________________________________________________________________
Post your free ad now! http://personals.yahoo.ca
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list