13.5 Attributes

The attributes of an object are filters (see Filters) that describe knowledge about it.

An attribute is a unary operation without side-effects.

An object may store values of its attributes once they have been computed, and claim that it knows these values. Note that ``store'' and ``know'' have to be understood in the sense that it is very cheap to get such a value when the attribute is called again.

The stored value of an attribute is in general immutable (see Mutability and Copyability), except if the attribute had been specally constructed as ``mutable attribute''.

It depends on the representation of an object (see Representation) which attribute values it stores. An object in the representation IsAttributeStoringRep stores all attribute values once they are computed. Moreover, for an object in this representation, subsequent calls to an attribute will return the same object; this is achieved via a special method for each attribute setter that stores the attribute value in an object in IsAttributeStoringRep, and a special method for the attribute itself that fetches the stored attribute value. (These methods are called the ``system setter'' and the ``system getter'' of the attribute, respectively.)indexsystem getterindexsystem setter

Note also that it is impossible to get rid of a stored attribute value because the system may have drawn conclusions from the old attribute value, and just removing the value might leave the data structures in an inconsistent state. If necessary, a new object can be constructed.

Properties are a special form of attributes that have the value true or false, see section Properties.

All attributes in the library are created during initialization, in particular they are not created dynamically at runtime.

Examples of attributes for multiplicative elements are Inverse, One, and Order. Size is an attribute for domains, Centre is an attribute for magmas, and DerivedSubgroup is an attribute for groups.

  • KnownAttributesOfObject( object ) O

    returns a list of the names of the attributes whose values are known for object.

    gap> g:=Group((1,2),(1,2,3));;Size(g);;
    gap> KnownAttributesOfObject(g);
    [ "Size", "One", "NrMovedPoints", "MovedPoints", 
      "GeneratorsOfMagmaWithInverses", "MultiplicativeNeutralElement", "Pcgs", 
      "StabChainMutable", "StabChainOptions" ]
    

    Several attributes have methods for more than one argument. For example IsTransitive (see IsTransitive.oprt) is an attribute for a G-set that can also be called for the two arguments, being a group G and its operation domain. If attributes are called with more than one argument then the return value is not stored in any of the arguments.

    [Top] [Previous] [Up] [Next] [Index]

    GAP 4 manual
    February 2000