[GAP Forum] Pointing objects and how to detect it

Mathieu Dutour mathieu.dutour at gmail.com
Thu Nov 8 11:02:20 GMT 2018


I have a question about memory management in GAP.

If we do
eList:=[0,0,0,0];
eL2:=[];
Add(eL2, eList);
Add(eL2, eList);
The state of eL2 is then [ [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ] ]
Now if we do eL2[1][1]:=1 then we have eL2 being
[ [ 1, 0, 0, 0 ], [ 1, 0, 0, 0 ] ]
because eL2 actually contains two pointers to eList.

On the other hand, if we write eL3:=[ [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ] ];
and do eL3[1][1]:=1 then we have eL3 being [ [ 1, 0, 0, 0 ], [ 0, 0, 0, 0 ]
].

Therefore the GAP object behavior depend on the way they are
constructed.

If one is given a matrix, is there a way to identify which one are pointing
to another object? Because right now if one does not know how the objects
are built then I do not know how to do it.

  Mathieu


More information about the Forum mailing list