Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GAP: add and use ReplaceBinding helper #1085

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions gap/exec.g
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
BindGlobal("_ORIG_ExecuteProcess", ExecuteProcess);
MakeReadWriteGlobal("ExecuteProcess");
ExecuteProcess := Julia.GAP.GAP_ExecuteProcess;
MakeReadOnlyGlobal("ExecuteProcess");
ReplaceBinding("ExecuteProcess", Julia.GAP.GAP_ExecuteProcess);
17 changes: 17 additions & 0 deletions gap/systemfile.g
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Helper for replacing a GAP global variable or function by a new value.
# The original value is retained under the name `_ORIG_***`
BIND_GLOBAL("ReplaceBinding", function(name, val)
local orig_name;
# Store a copy of the original value, but only if that copy does not yet
# exist. This ensures we don't overwrite it during a call to `Reread`.
orig_name := "_ORIG_";
APPEND_LIST_INTR(orig_name, name);
if not ISB_GVAR(orig_name) then
ASS_GVAR(orig_name, VAL_GVAR(name));
MakeReadOnlyGVar(orig_name);
fi;
MakeReadWriteGVar(name);
ASS_GVAR(name, val);
MakeReadOnlyGVar(name);
end);

(function()
local deps;

Expand Down
Loading