Prolog permits this but it is bad programming style ---unless you are intending to write programs to modify themselves.
It is usually better to consider carrying around the wanted information as an extra argument in all the relevant clauses.