Unless there is some other requirement, doesn't this work?
h(n):= concat(foo,n)
then h(1) creates foo1.
You can figure out more elaborate name schemes from this
model, using intern and format from lisp..
h(n):= ?intern(?format(false,"$FOO~s",n));
h(1);
there is also, in Maxima,
gensym(foo);
but that uses its own number, not 1.