Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 418346/****************************************************************************1**2*W gvars.h GAP source Martin Schönert3**4**5*Y Copyright (C) 1996, Lehrstuhl D für Mathematik, RWTH Aachen, Germany6*Y (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland7*Y Copyright (C) 2002 The GAP Group8**9** This file declares the functions of the global variables package.10**11** The global variables package is the part of the kernel that manages12** global variables, i.e., the global namespace. A global variable binds an13** identifier to a value.14**15** A global variable can be automatic. That means that the global variable16** binds the identifier to a function and an argument. When the value of17** the global variable is needed, the function is called with the argument.18** This function call should, as a side-effect, execute an assignment of a19** value to the global variable, otherwise an error is signalled.20**21** A global variable can have a number of internal copies, i.e., C variables22** that always reference the same value as the global variable. In fact the23** internal copies are only used for functions, i.e., the internal copies24** only reference the same value as the global variable if it is a function.25** Otherwise the internal copies reference functions that signal an error.26*/2728#ifndef GAP_GVARS_H29#define GAP_GVARS_H303132/****************************************************************************33**34*V ValGVars . . . . . . . . . . . . . . . . . . values of global variables35*V PtrGVars . . . . . . . . . . . . . pointer to values of global variables36**37** 'ValGVars' is the bag containing the values of the global variables.38**39** 'PtrGVars' is a pointer to the 'ValGVars' bag. This makes it faster to40** access global variables.41*/42extern Obj ValGVars;4344extern Obj * PtrGVars;454647/****************************************************************************48**49*F VAL_GVAR(<gvar>) . . . . . . . . . . . . . . . value of global variable50**51** 'VAL_GVAR' returns the value of the global variable <gvar>. If <gvar>52** has no assigned value, 'VAL_GVAR' returns 0. In this case <gvar> might53** be an automatic global variable, and one should call 'ValAutoGVar', which54** will return the value of <gvar> after evaluating <gvar>-s expression, or55** 0 if <gvar> was not an automatic variable.56*/57#define VAL_GVAR(gvar) PtrGVars[ (gvar) ]585960/****************************************************************************61**62*V WriteGVars . . . . . . . . . . . . . writable flags of global variables63*/64extern Obj WriteGVars;656667/****************************************************************************68**69*V ErrorMustEvalToFuncFunc . . . . . . . . . function that signals an error70**71** 'ErrorMustEvalToFuncFunc' is a (variable number of args) function that72** signals the error ``Function: <func> be a function''.73*/74extern Obj ErrorMustEvalToFuncFunc;757677/****************************************************************************78**79*V ErrorMustHaveAssObjFunc . . . . . . . . . function that signals an error80**81** 'ErrorMustHaveAssObjFunc' is a (variable number of args) function that82** signals the error ``Variable: <<unknown>> must have an assigned value''.83*/84extern Obj ErrorMustHaveAssObjFunc;858687/****************************************************************************88**89*F AssGVar(<gvar>,<val>) . . . . . . . . . . . . assign to a global variable90**91** 'AssGVar' assigns the value <val> to the global variable <gvar>.92*/93extern void AssGVar (94UInt gvar,95Obj val );969798/****************************************************************************99**100*F ValAutoGVar(<gvar>) . . . . . . . . value of a automatic global variable101**102** 'ValAutoGVar' returns the value of the global variable <gvar>. This will103** be 0 if <gvar> has no assigned value. It will also cause a function104** call, if <gvar> is automatic.105*/106extern Obj ValAutoGVar (107UInt gvar );108109110/****************************************************************************111**112*F NameGVar(<gvar>) . . . . . . . . . . . . . . . name of a global variable113**114** 'NameGVar' returns the name of the global variable <gvar> as a C string.115*/116extern Char * NameGVar (117UInt gvar );118119120/****************************************************************************121**122*F NameGVarObj(<gvar>) . . . . . . . . . . . . . name of a global variable123**124** 'NameGVarObj' returns the name of the global variable <gvar> as a GAP125** string.126*/127extern Obj NameGVarObj (128UInt gvar );129130131/****************************************************************************132**133*F GVarName(<name>) . . . . . . . . . . . . . . global variable for a name134**135** 'GVarName' returns the global variable with the name <name>.136*/137extern UInt GVarName (138const Char * name );139140141/****************************************************************************142**143*V Tilde . . . . . . . . . . . . . . . . . . . . . . . . global variable '~'144**145** 'Tilde' is the identifier for the global variable '~', the one used in146** expressions such as '[ [ 1, 2 ], ~[1] ]'.147**148** Actually when such expressions appear in functions, one should probably149** use a local variable. But for now this is good enough.150*/151extern UInt Tilde;152153154/****************************************************************************155**156*F iscomplete_gvar( <name>, <len> ) . . . . . . . . . . . . . check <name>157*/158extern UInt iscomplete_gvar (159Char * name,160UInt len );161162163/****************************************************************************164**165*F completion_gvar( <name>, <len> ) . . . . . . . . . . . . find completion166*/167extern UInt completion_gvar (168Char * name,169UInt len );170171172/****************************************************************************173**174*F MakeReadOnlyGVar( <gvar> ) . . . . . . make a global variable read only175*F MakeReadWriteGVar( <gvar> ) . . . . . . make a global variable read-write176*/177extern void MakeReadOnlyGVar (178UInt gvar );179180extern void MakeReadWriteGVar (181UInt gvar );182183extern Int IsReadOnlyGVar (184UInt gvar );185186/****************************************************************************187**188189*F * * * * * * * * * * * * * copies and fopies * * * * * * * * * * * * * * *190*/191192193/****************************************************************************194**195196*F InitCopyGVar( <name>, <copy> ) . . declare C variable as copy of global197**198** 'InitCopyGVar' makes the C variable <cvar> at address <copy> a copy of199** the global variable named <name> (which must be a kernel string).200**201** The function only registers the information in <CopyAndFopyGVars>. At a202** latter stage one has to call 'UpdateCopyFopyInfo' to actually enter the203** information stored in <CopyAndFopyGVars> into a plain list.204**205** This is OK for garbage collection, but a real problem for saving in any206** event, this information does not really want to be saved because it is207** kernel centred rather than workspace centred.208**209** Accordingly we provide two functions `RemoveCopyFopyInfo' and210** `RestoreCopyFopyInfo' to remove or restore the information from the211** workspace. The Restore function is also intended to be used after212** loading a saved workspace213*/214extern void InitCopyGVar (215const Char * name ,216Obj * copy );217218219/****************************************************************************220**221*F InitFopyGVar( <name>, <copy> ) . . declare C variable as copy of global222**223** 'InitFopyGVar' makes the C variable <cvar> at address <copy> a (function)224** copy of the global variable <gvar>, whose name is <name>. That means225** that whenever the value of <gvar> is a function, then <cvar> will226** reference the same value (i.e., will hold the same bag identifier). When227** the value of <gvar> is not a function, then <cvar> will reference a228** function that signals the error ``<func> must be a function''. When229** <gvar> has no assigned value, then <cvar> will reference a function that230** signals the error ``<gvar> must have an assigned value''.231*/232extern void InitFopyGVar (233const Char * name,234Obj * copy );235236237/****************************************************************************238**239*F UpdateCopyFopyInfo() . . . . . . . . . . convert kernel info into plist240*/241extern void UpdateCopyFopyInfo ( void );242243244/****************************************************************************245**246*F RemoveCopyFopyInfo() . . . remove the info about copies of gvars from ws247*/248extern void RemoveCopyFopyInfo( void );249250251/****************************************************************************252**253*F RestoreCopyFopyInfo() . . . restore the info from the copy in the kernel254*/255extern void RestoreCopyFopyInfo( void );256257258259/****************************************************************************260**261262*F * * * * * * * * * * * * * initialize package * * * * * * * * * * * * * * *263*/264265266/****************************************************************************267**268269*F InitInfoGVars() . . . . . . . . . . . . . . . . . table of init functions270*/271StructInitInfo * InitInfoGVars ( void );272273274#endif // GAP_GVARS_H275276/****************************************************************************277**278279*E gvars.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . ends here280*/281282283