There is no easy way of making a function private in GAP.

Some packages make a single record (for example semigroups make SEMIGROUPS, 
ferret makes _FerretHelperFuncs), and put private functions as members of this 
record -- users are unlikely to dig into such records, and you can document 
they should not call such functions. This is enough for most packages, and 
there exist packages with kernel extensions where digging into undocumented 
functions can crash or corrupt GAP -- users are expected to not do so.


Technically, it is possible to make entirely private functions, by making an 
unnamed function and immediately executing it (but I wouldn't do this, I just 
mention it for completeness. This is a common technique in Javascript). The 
below code makes a new function which takes no arguments, and then immediately 
executes it. This creates the global name "PublicFunc", but privatefunc cannot 
be accessed.

(function()
local privatefunc;
privatefunc := function(x) return x + 1; end;

# Or you can use InstallFunction, etc.
BindGlobal("PublicFunc",
function(x)
  return privatefunc(x) + 6; 
end);

end)();



-----Original Message-----
From: Mathieu Dutour <mathieu.dut...@gmail.com> 
Sent: 27 October 2020 11:04
To: forum@gap-system.org
Subject: {Suspected Spam} [GAP Forum] Private function of a package

Dear all,

I am working to make my package for polyhedral computation "polyhedral" (see 
e.g.
http://mathieudutour.altervista.org/Polyhedral/index.html)
as a normal regular package for GAP.

I would like to have some function of this package to be used only internally 
and not put available to users. Is that possible?

  Mathieu
_______________________________________________
Forum mailing list
Forum@gap-system.org
https://mail.gap-system.org/mailman/listinfo/forum

_______________________________________________
Forum mailing list
Forum@gap-system.org
https://mail.gap-system.org/mailman/listinfo/forum

Reply via email to