How to write a function which may return noun form of itself in Maxima language



Dear maxima users,

Is there a suggested way to write a function in Maxima language which
may return its noun form if it cannot process the arguments?

Let me explain the issue with the following example:
The (%i27) defines a function which returns its noun form if the argument is
not a number.
(%i27) f(x):=if numberp(x) then x^2 else 'f(x)$

(%i28) f(n+3);
(%o28) 'f(n+3)
So far it seems working as defined.

(%i29) %,n:5;
(%o29) 'f(8)

(%i30) %,nouns;
(%o30) 64
With additional informations, I can continue to compute using nouns flag.
All this seems good. However:

(%i31) f(n+3);
(%o31) 'f(n+3)

(%i32) %,nouns;

This rather simpler example at (%i32), it never returns. It looks like the
infinite recursive loop happens.

I noticed that if everything is written in Lisp, then the above infinite
loop
can be avoided. integrate() and sum() functions does not cause such
loop when evaluated with nouns.

So my question is, is there any suggested way to write a function that
may return noun form of itself, without causing infinite loop when evaluated
with the noun flag set?

Thanks and best regards,
Yasuaki Honda, Chiba, Japan

Imaxima and Imath maintainer