A problem with the bug ID:1994295 - errormsg



I have committed code in mlisp.lisp revision 1.87 which prevents the
setting of the global errormsg always to NIL, when it is used in a
block. This part of the code works as expected. This is the reported
problem.

But I have overseen a second problem: The local setting of the option
variable errormsg does not work too.

Tracing the involved routines all seems to look fine:

The following function shows the behavior for the variables errormsg and
gamma_expand. The default value of errormsg is TRUE and of gamma_expand
is FALSE.

(%i86) f(x):=block([errormsg:x,gamma_expand:true], print("errormsg =
",errormsg), print("gamma_expand = ", gamma_expand))$

-> We try to set errormsg locally to the value FALSE

(%i87) f(false);

  0: (MBIND ($ERRORMSG $GAMMA_EXPAND) (NIL T) NIL)
    1: (MBIND-DOIT ($ERRORMSG $GAMMA_EXPAND) (NIL T) NIL)

-> At this point errormsg is set to FALSE as expected.

      2: (MSET $ERRORMSG NIL)
errormsg SET TO false
      2: MSET returned NIL

For comparison the setting of the variable gamma_expand to TRUE.

      2: (MSET $GAMMA_EXPAND T)
gamma_expand SET TO true
      2: MSET returned T
    1: MBIND-DOIT returned NIL
  0: MBIND returned NIL

-> Here is the problem. We execute the commands of the function f(x). 
-> At this point we print the value of errormsg, but it is TRUE and not 
-> the expected value FALSE we have assigned above.

errormsg =  true 

-> We do not have the problem with any other variable. This is the 
-> correct local value of gamma_expand:

gamma_expand =  true 

-> We leave the block and restore the global values. Both variables
-> gamma_expand and errormsg are restored to their standard values. 
-> The correct setting of errormsg has been corrected with the 
-> committed code in mlisp.lisp revision 1.87.

  0: (MSET $GAMMA_EXPAND NIL)
gamma_expand SET TO false
  0: MSET returned NIL
  0: (MSET $ERRORMSG T)
errormsg SET TO true
  0: MSET returned T


The local assignment does not work, because during the execution of the
routine mbind-doit we are in a let-binding of errormsg. After executing
mbind-doit we leave this let-binding and the local assignment of
errormsg is lost.

Summary:

1. 
When the variable errormsg is used in a block, the value of errormsg is
restored to the correct global value after finishing the function.

2.
A local assignment to errormsg does not work, because during the
execution of the related code, we are within a let-binding of errormsg.


I have no idea how to correct the second problem and it might not be
worse the effort. Perhaps, we only should document that the variable
errormsg can not be used as a local variable in a block. 

In view of this we might consider to revert the change of mlisp.lisp
revision 1.87, to close this bug report as "won't fix" and to add a
warning about this behavior to the documentation. 


Dieter Kaiser