[DGD] Re: recompile() question

harte at xs4all.nl harte at xs4all.nl
Fri Dec 26 10:13:22 CET 1997


Quoting Jason's message from 25 Dec:
[...]
| Ok, so there are our 2 objects.  Simple enough.  It can be assumed that
| create() is the function called when the object is loaded by DGD.  So when I
| load object A and do Object A -> query_string() I get "This is a test".  So,
| without destructing either object, I change the create() function in object
| A from set_string("This is a test"); to set_string("Blah");.  If I do
| *either* compile_object(Object A) *or* destruct_object(Object B) -
| compile_object(Object A) and I do Object A -> query_string() I still get
| "This is a test" and not "Blah".

That's because recompiling does -NOT- cause any functions to be called.
Certainly not the standard initialization function, which in most cases
would mess up an object's internal state quite a bit.

If you want, you could add (in the new code) a function called
upgraded() or so that does a few things -- such as set_string("Blah");
in this case -- and call that one yourself.

[...]
| I guess this is my fundamental question:  Upon compiling an
| already-loaded object, is the "create" function called in that object?  Or
| is that only reserved for first-time compilation?

1. No. 2. Yes.  As I `explained' just now.

| I know you can force the
| call, but it would make sense to me that DGD would invoke the "create"
| function if you compile an already-loaded object that's different than the
| existing copy.
|
| Thoughts?  Suggestions?  Counter-examples? :)

It would definitely not make sense to call the same initialization
function as is called for the first compile.  Suppose you initialize a
complex mapping data-structure with an empty mapping in the create()
function which is then in the course of time extended and at some point
you decide to fix part of the code of this object, and DGD happily
calls create() again, (re)initializing your data-structure with an
empty mapping.  You wouldn't be very much amused, would you? :)

The suggestion I have, I already gave at the beginning of this message,
call a different function, one that is added especially for the
occasion of this upgrade and serves no other purpose at all.

Hope that helps,

Erwin.
-- 
  Erwin Harte   Programmer :   Unix is an operating system, OS/2 is
             -+-           :  half an operating system, Windows is a
  Email: harte @ xs4all.nl : shell, and Dos is a boot partition virus




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



More information about the DGD mailing list