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-boun...@gap-system.org on behalf of Rafael Villarroel" <forum-boun...@gap-system.org on behalf of rafa...@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@mail.gap-system.org >http://mail.gap-system.org/mailman/listinfo/forum _______________________________________________ Forum mailing list Forum@mail.gap-system.org http://mail.gap-system.org/mailman/listinfo/forum