Sometimes it is useful to make a small local piece of code inside a proc, with its
own local variables that do not interfere with the variables of the proc. In Ada,
this is done using declare clause for example. In Maple on can do the same as
follows
restart; foo:=proc() local n; n:=10; proc() local n; n:=99; print("inside inner proc, n=",n); end proc(); print("n=",n); end proc; foo();
Which prints
Notice the end of the inner anonymous proc above. It has end proc(); and
not end proc; as normal proc. This defines the inner proc and calls it at same
time. All the local variables inside the anonymous proc only exist inside that
proc and go away after the call, and they do not interfere with the outer proc
variables. This way we can declare temporary variables and use them where they are
needed.