Skip to content

Conversation

@ThomasBreuer
Copy link
Contributor

addresses #6173

@ThomasBreuer ThomasBreuer added kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements topic: documentation Issues and PRs related to documentation release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes labels Dec 11, 2025
@lgoettgens lgoettgens linked an issue Dec 12, 2025 that may be closed by this pull request
Comment on lines +62 to +66
## It may, however, happen that some ⪆ function runs into an error
## when it is called with elements with memory.
## In such cases, probably a method for elements with memory is missing,
## and perhaps some existing methods are installed with too weak
## requirements.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an end user, I think I'd find this paragraph frustrating: it describes a problem but gives no hint as to how to resolve it.

Perhaps we can offer some solutions:

  • add your own method, by looking at the methods in lib/memory.gi and adapting them
  • contact GAP support / write an issue and requesting this, and we might add it for you
  • .... anything else?

Also perhaps we could list which operations are currently supported / "wrapped"?

It might also make sense that these things are written mainly with groups in mind, and are tested relatively well for permutations and (quadratic) matrices, and nothing else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.
I will provide a utility function that creates an overview of the currently supported methods for objects with memory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on our last discussion, it seems you are working on a serious text addressing this point.

Which I think is great, but perhaps we should not let the perfect be the enemy of the good, and first get this PR merged? It seems to me that this point here could already be improved by stating something like. "In this case, additional methods may have to be defined. Please contact GAP support if you run into such a problem and need help."

This can then later be replaced by your better text. But at least the rest of this PR does not need to stay open for an extended time, and people can benefit from it sooner.

#############################################################################
##
## <#GAPDoc Label="objwithmemory">
## The idea behind objects with memory is as follows.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other communities refer to this as "tracing" / "tracing operations". Perhaps we could bring that up, briefly, it might help some people?

##
DeclareOperation( "StripMemory", [ IsObject ] );

DeclareOperation( "ForgetMemory", [ IsObject ] );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering why we even need ForgetMemory ; looking at the methods defined here in GAP, it would seem that ForgetMemory(x); could always be replaced by x := List(x, StripMemory);.

But it turns out it is mainly useful due to its method installed in the genss ("for a stabilizer chain") and orb ("for an orbit object") packages. Then recog uses the one in genss, which in turn uses the one in orb.


DeclareOperation( "ForgetMemory", [ IsObject ] );

DeclareGlobalFunction( "StripStabChain" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that StripStabChain really should be turned into a method for ForgetMemory -- and also that it should in turn perhaps make use of ForgetMemory ?


DeclareOperation( "ForgetMemory", [ IsObject ] );

DeclareGlobalFunction( "StripStabChain" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that StripStabChain really should be turned into a method for ForgetMemory -- and also that it should in turn perhaps make use of ForgetMemory ?

UPDATE: ah I see you in fact did change it to use ForgetMemory, excellent!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logically, StripStabChain does what ForgetMemory is intended for.
However, stabilizer chains are plain records, and installing a method for a record would require some additional checks. Since StripStabChain is not used in the library, I left the name and kept the function undocumented.

##
DeclareOperation( "StripMemory", [ IsObject ] );

DeclareOperation( "ForgetMemory", [ IsObject ] );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering why we even need ForgetMemory ; looking at the methods defined here in GAP, it would seem that ForgetMemory(x); could always be replaced by x := List(x, StripMemory);.

But it turns out it is mainly useful due to its method installed in the genss ("for a stabilizer chain") and orb ("for an orbit object") packages. Then recog uses the one in genss, which in turn uses the one in orb.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My interpretation was that the main purpose of ForgetMemory is that it works in place. This is how the function StripStabChain uses it.
By not documenting the function, I have postponed the decision whether the function is needed.


DeclareGlobalFunction( "StripStabChain" );

DeclareGlobalFunction( "CopyMemory" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not aware of any code using this. It seems rather dangerous. Ah well.

lib/memory.gi Outdated
Comment on lines 189 to 190
return ObjWithMemory( slp, b!.n, b!.el );
#T why can't we return b?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, beats me. The line was added by checks notes one Thomas Breuer, in PR #5875, but to be fair, the code before was essentially equivalent.

I'd be willing to change it and try what happens...?

Suggested change
return ObjWithMemory( slp, b!.n, b!.el );
#T why can't we return b?
return b;

lib/memory.gi Outdated
Comment on lines 192 to 193
return ObjWithMemory( slp, a!.n, a!.el );
#T why can't we return a?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return ObjWithMemory( slp, a!.n, a!.el );
#T why can't we return a?
return a;

lib/memory.gi Outdated
Comment on lines 219 to 220
return ObjWithMemory( slp, 0, a!.el );
#T why can't we return a?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return ObjWithMemory( slp, 0, a!.el );
#T why can't we return a?
return a;

@fingolfin
Copy link
Member

This is great, thanks a lot @ThomasBreuer ! I only left some minor nitpicks

Concerning the question what to do when objects with memory
cause GAP errors,
add and document `MethodsForObjWithMemory`.

For better reference, document also `MethodsOperation`.

And fix some GAPDoc syntax.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes topic: documentation Issues and PRs related to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document objects with memory

2 participants