[GAP Forum] can one define identifiers like f1, f2, f3 in an automatic way?

Max Neunhoeffer neunhoef at mcs.st-and.ac.uk
Mon Mar 21 09:36:04 GMT 2011


Dear Forum, dear Igor,

there are actually officially documented functions
  ValueGlobal
  IsBoundGlobal
  UnbindGlobal

Strangely, we are missing "AssignGlobal" which we probably should add
for the next release. "BindGlobal" does work for this purpose but
automatically write-protects the global variable.
So as Alexander writes, in the released version of GAP one probably
would use the (undocumented and internal) function ASS_GVAR. 
Of course, one could do
  BindGlobal(st,value);
  MakeReadWriteGVar(st);
but this would be less efficient.

Note also that there is the officially documented function
  EvalString
which might be useful here. It evaluates a single expression given as
a string and returns the result. Internally it currently creates an
InputTextStream and runs "Read" on it.

Finally, if you are happy to store your values in a record r you can
do things like
  r.(st) := 17;
If st is a string with value "abc", then this assigns 17 to the
component
  r.abc

Depending on your applications this might be a way to go which does
not use the global namespace.

Best regards,
  Max.

-- 
Max Neunhoeffer              http://www-groups.mcs.st-and.ac.uk/~neunhoef/
> > > > > > > > > > >  May the Source be with you! < < < < < < < < < < < < 
The University of St Andrews is a registered Scottish charity: No SC013532




More information about the Forum mailing list