[GAP Forum] Input stream inside a function

Anvita anvita21 at gmail.com
Fri Apr 18 10:24:28 BST 2008


Dear Forum,

Please, explain to me why the following function does not work:

-------------------------------
F:=function(a)
local b;
Read(InputTextString("b:=a;"));
return b;
end;
-------------------------------

I expected that, for example, F(1) would equal 1.
However, GAP returns an error:

----------------------------------------------------
gap> F(1);
Variable: 'a' must have a value

Variable: 'b' must have an assigned value at
return b;
 called from
<function>( <arguments> ) called from read-eval-loop
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can 'return;' after assigning a value to continue
-----------------------------------------------------

The code does work in the main read-eval-print loop, though:

------------------------------------
gap> a:=1;
1
gap> Read(InputTextString("b:=a;"));
gap> b;
1
------------------------------------

Thank you,
Anvita



More information about the Forum mailing list