| ### 3.7.4 Names in procedures All variables defined inside a procedure are local to the procedure and their names cannot interfere with names in other procedures. Without further action, they are automatically deleted after leaving the procedure. To keep local variables and their value after leaving the procedure, they have to be exported (i.e. made global) by a command like `export` or `exportto` (see export,see exportto, see importfrom; see package). To return the value of a local variable, use the `return` command (see return). Example:
    proc xxx
    {
      int k=4;        //defines a local variable k
      int result=k+2;
      export(result);  //defines the global variable "result".
    }
    xxx();
    listvar(all);
    ==> // result                         [0]  int 6
Note that the variable `result` became a global variable after the execution of `xxx`.

User manual for Singular version 4.4.1, 2025, generated by texi2html.