Question: why calling deep call on object makes it no longer possible to create new instances of the class?

This is another bizzar behaviour of objects. I created a basic object of type person.  Noticed that after issuing the call copy(object,deep) and not doing anything at all with the result. Just made the call only, then I am not longer able to create new objects of this class. I had to restart the session to be able to create new objects again.

Why?  This seems like something went messy with memory layout. I put a print message in the constructor, and see that this message no longer show up  after the call copy(object,deep) even though this call was not used for any purpose as you see, but to only to see its effect on the session.

Any explanation why one can no longer create new objects after doing this?  Here is the workseet


 

interface(version)

`Standard Worksheet Interface, Maple 2022.1, Windows 10, May 26 2022 Build ID 1619613`

restart;

person:=module()
    option object;
    export name::string:="";  

    export ModuleCopy::static:=proc(_self,proto, name::string, $)
      print("Enter constructor of person");
      _self:-name := name;
    end proc;
end module;

_m2370471750336

p1:=Object(person,"me");
p1:-name;
do_not_care := copy(p1,deep);  

"Enter constructor of person"

_m2370557462816

"me"

_m2370557440576

p2:=Object(person,"me");  #WHy constructor no long called?
p2:-name;   #this no longer work.

_m2370556941056

""

p3:=Object(person,"me");  #WHy constructor no long called?
p3:-name;   #this no longer work.

_m2370556932032

""

restart;  #had to call restart to fix things.

person:=module()
    option object;
    export name::string:="";  

    export ModuleCopy::static:=proc(_self,proto, name::string, $)
      print("Enter constructor of person");
      _self:-name := name;
    end proc;
end module;

_m2370471750336

p4:=Object(person,"me");  #now it works again
p4:-name;   

"Enter constructor of person"

_m2370557462816

"me"

 


 

Download deep_call_problem.mw

Please Wait...