3.3 Creating Attributes and Properties

  • NewAttribute( name, filt )
    NewAttribute( name, filt, rank )

    NewAttribute returns a new attribute attr with name name (see also Attributes in the Reference Manual). The filter filt describes the involved filters of attr (see Filters in the Reference Manual). That is, the argument for attr is expected to lie in filt.

    Each method for attr that does not require its argument to lie in filt must be installed using InstallOtherMethod.

    Contrary to the situation with categories and representations, the tester of attr does not imply filt. This is exactly because of the possibility to install methods that do not require filt.

    For example, the attribute Size was created with second argument a list or a collection, but there is also a method for Size that is applicable to a character table, which is neither a list nor a collection.

    The optional third argument rank denotes the incremental rank (see Filters in the Reference Manual) of the tester of attr, the default value is 1.

  • NewAttribute( name, filt, "mutable" )
    NewAttribute( name, filt, "mutable", rank )

    If the third argument is the string "mutable", the stored values of the new attribute are not forced to be immutable. This is useful for an attribute whose value is some partial information that may be completed later. For example, there is an attribute ComputedSylowSubgroups for the list holding those Sylow subgroups of a group that have been computed already by the function SylowSubgroup, and this list is mutable because one may want to enter groups into it as they are computed.

  • NewProperty( name, filt )
    NewProperty( name, filt, rank )

    NewProperty returns a new property prop with name name (see also Properties in the Reference Manual). The filter filt describes the involved filters of prop. As in the case of attributes, filt is not implied by prop.

    The optional third argument rank denotes the incremental rank (see Filters in the Reference Manual) of the property prop itself, i.e. not of its tester, the default value is 1.

    Each method that is installed for an attribute or a property via InstallMethod must require exactly one argument, and this must lie in the filter filt that was entered as second argument of NewAttribute resp. NewProperty.

    As for any operation (see Creating Operations), for attributes and properties one can install a method taking an argument that does not lie in filt via InstallOtherMethod, or a method for more than one argument; in the latter case, clearly the result value is not stored in any of the arguments.

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

    GAP 4 manual
    February 2000