Is it possible to preserve variable names when writing and reading term programatically?
问题 I'm trying to write an SWI-Prolog predicate that applies numbervars/3 to a term's anonymous variables but preserves the user-supplied names of its non-anonymous variables. I eventually plan on adding some kind of hook to term_expansion (or something like that). Example of desired output: ?- TestList=[X,Y,Z,_,_]. > TestList=[X,Y,Z,A,B]. This answer to the question Converting Terms to Atoms preserving variable names in YAP prolog shows how to use read_term to obtain as atoms the names of the