[GAP Forum] Why do my objects do not store attributes?

Christopher Jefferson caj21 at st-andrews.ac.uk
Fri May 27 22:39:56 BST 2016


I’m not claiming this is obvious, but the definition of StrType has to have IsAttributeStoringRep:

StrType := NewType(StrFamily, IsMyStruct and IsAttributeStoringRep);

Chris

On 27/05/2016, 22:11, "forum-bounces at gap-system.org on behalf of Rafael Villarroel" <forum-bounces at gap-system.org on behalf of rafaelv at uaeh.edu.mx> wrote:

>
>Hello GAP forum
>
>I'm puzzled as to why the following code, which I think should work,
>does not. I have reduced the situation to the following:
>
>--------------- start tempo.gap
>
>DeclareCategory("IsMyStruct", IsObject);
>StrFamily := NewFamily("MyStructsFamily");
>StrType := NewType(StrFamily, IsMyStruct);
>DeclareRepresentation("StrRep",
>                      IsComponentObjectRep and IsAttributeStoringRep,
>                      ["uno", "dos"]);
>CreateStr := function(u,v)
>    return Objectify(StrType,rec(uno:=u,dos:=v));
>end;
>
>InstallMethod(PrintObj,[IsMyStruct],function(S) Print("uno=",S!.uno,"dos=",S!.dos);
>                                    end);
>InstallMethod(ViewObj,[IsMyStruct],function(S) Print("uno=",S!.uno,"dos=",S!.dos);
>              end);
>
>DeclareAttribute("MyAtr",IsMyStruct);
>InstallMethod(MyAtr,[IsMyStruct],function(S) return("hello");
>                                 end);
>
>DeclareProperty("MyProp",IsMyStruct);
>InstallMethod(MyProp,[IsMyStruct],function(S) return false;
>                                 end);
>
>--------------- end tempo.gap
>
>then, after loading in a GAP 4.8.2 session, started with "gap -r":
>I get:
>
>gap> Read("tempo.gap");
>gap> S:=CreateStr(1,2);
>uno=1dos=2
>gap> MyAtr(S);
>"hello"
>gap> KnownAttributesOfObject(S);
>[  ]
>
>why is that? However, storing of properties work?
>
>gap> MyProp(S);
>false
>gap> KnownPropertiesOfObject(S);
>[ "MyProp" ]
>
>Thanks in advance for any help.
>
>Rafael
>
>
>
>
>
>
>
>
>
>_______________________________________________
>Forum mailing list
>Forum at mail.gap-system.org
>http://mail.gap-system.org/mailman/listinfo/forum



More information about the Forum mailing list