Question: Question about subprocedure

Here is one I have been struggling with lately:

I have a relatively large module with many procedures inside (plus some other data structures). In one of the procedures, it turns out that it would be convenient to have a subprocedure defined inside to both shorten the code by avoiding duplication as well as make it more error proof (once the subprocedure is debugged it'll be correct everywhere it is used). Here is the skeleton

Lattice:=module() option package;
export Track;   ...
   Track:=proc(arguments) uses LinearAlgebra;
   local trackElement;
      ...

      for ... do
         result:=trackElement(parms); # This does not work
         ...
      end do

      trackElement:=proc(arguments) uses LinearAlgebra;
         ...
      end proc; # trackElement

   end proc; # Track;

end module; # Lattice

The problem I have is that procedure trackElement is not recognized as i found out running the code in the debugger. I can make it work by taking trackElement out of Track and make it local to the Lattice module. While functionally this works (and it is how I have it now programmed), I do  not like it as every proc in the Lattice module can see trackElement. That should not be so, I want it local to procedure Track, which is where it belongs.

I really thought I could define procedures within procedures. Am I wrong? Or is there something else ging on?

TIA,

Mac Dude

PS: The whole module is more than 100 kB of Maple code sitting in a library. I refrain from uploading it here as it would be non-trivial to get going even for a simple test case.

Please Wait...