Carl's solution is the standard way to handle this. If you need independent incrementers, one approach is to use a Maple object, which is an extension of a module. A practical disadvantage to using an object is that the calling notation is a bit clunky, at least for something as simple as an incrementer. For example, rather than inc() to return the incremented value, one might have to call increment(inc). To avoid that clunkiness, the following code overloads the unary Maple ! operator to act as the incrementer of the object. Overloading a unary + operator would be nicer, but that isn't possible (the unary - operator can be overloaded, but that seems backwards, though it would be useful for a decrement operation.).
Incrementer := module()
local cnt := 0;
ModuleCopy :: static := proc(self :: Incrementer
, proto :: Incrementer
self:-cnt := 0;
`!` :: static := proc(self :: Incrementer)
self:-cnt := self:-cnt + 1;
The following is a typical usage
> cnt1 := Object(Incrementer):
> cnt2 := Object(Incrementer):
The curious reader may wonder why one cannot overload the unary + operator. The reason is that it doesn't really exist in Maple. The expression +x is handled by the Maple simplifier and converted to just x. One could overload the nary + operator by overloading the `+` function, but then the call to the incrementer would be `+`(cnt1), which is not so nice (at least from my perspective).