Dear GAP Forum,
Jose Morais wrote:
I have an attribute defined for an object that is declared as
IsAttributeStoringRep, but eventually I may need to update the value of
this attribute, is it possible? How?
There is no supported way of changing the value of an attribute, but you can
do the following (which is used in the library for example for storing
things such as sylow subgroups once they are computed):
First, declare the attribute in question as mutable, by adding a string
"mutable" as last argument:
DeclareAttribute("MyAttr",IsPiffle,"mutable");
Next, store in this attribute not the value you want to keep, but a list of
length 1 which contains this value. You can then change this value, for
example
MyAttr(piffle)[1]:=bla;
If you want to return the value to the user, not bothering with the list
make the attribute private to your code and just add a function
fct:=function(piffle)
return MyAttr(piffle)[1];
end;
I hope this helps,
Alexander Hulpke
-- Colorado State University, Department of Mathematics,
Weber Building, 1874 Campus Delivery, Fort Collins, CO 80523-1874, USA
email: hulpke@math.colostate.edu, Phone: ++1-970-4914288
http://www.math.colostate.edu/~hulpke