[DGD] Uninitialized variable error
Michael McKiel
crashnbrn71 at yahoo.ca
Fri Mar 26 13:17:00 CET 2004
--- Michael McKiel <crashnbrn71 at yahoo.ca> wrote: > I removed, the "str =
process_alias(str)" in the user's do_command()
> and replaced it with, str = ALIASD->process_alias(this_object(), str);
>
> And now, I don't get the: "history: wtf?? !history." message...
>
> so I guess I don't understand why if I do (in the user's do_command()):
> str = process_alias(str);
> which calls the inherit'ed function, process_alias(), which does:
> aliasd->process_alias(this_object(), str);
> and if I send a message to the driver before that call to print
> this_object's
> name, it IS /object/secure/user#51
>
> That bit of code/function calling causes some misdirection of the variables
> 'aliases' and 'history'.
>
> But if I skip the inherit'ed process_alias(), and just directly call
> str = ALIASD->process_alias(this_object(), str);
> in the user's do_command() everything is fine...
>
> So I've solved the problem, but I still don't understand why it was a
> problem
> to start with. Any takers? :)
>
Well sorry for spamming, which looks like me mostly talking to myself heh.
But the above didn't work, the process_alias() in aliasd, had a security
check of: if (previous_program() != LIB_ALIAS) return nil;
so it never actually got to the call to history().
What did work, was making these 2 variables private:
mapping aliases;
string *history;
adding an (and calling it in the user's create()):
void init_alias() {
aliases = ([ ]);
history = ({ });
}
What didn't work, was not having them private, and putting the init_alias()
function in the user.c
I guess it has to do with a quirk with inheritance that I'm not sure I get.
Because if the user object inherits a file, it inherits the variables...
And if you initialize the variables in the user object, like above,
then...what they are only initialized in the user object itself? and if you
use those variables within the inherit'ed LIB then its using the original
variables? But that can't really be true, because I inherit a lot of
variables from /inherit/common/thing.c into my user object, and I set them
within the user object, and they are mostly referenced within thing.c
So does it have to do with mapping/arrays and how when you pass an array, if
you don't explicitly copy it, and change the array it changes the original?
Again, that doesn't seem to make sense when talking about inheriting
mapping/arrays.
So is there some implicit rule that should be followed when inheriting files
that have mappings/arrays that you want each object to have their own copy
of? to make the variables private, and just reference them within the LIB and
provide functions to let the inheriting object access them?
______________________________________________________________________
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