Subject: write_term(Term, [variable_names(Vars)]) ?

From: Lourens van der Meij <[email-masked]>
Date: Tue, 29 Aug 2000 15:30:06 +0200 (CEST)

I could not find a write predicate in SWI-Prolog that writes terms such
that a variable Var occurring in the term is replaced by Name if there is
an entry Name = Var in a supplied Vars list,  complementary to
read_term(Term,[variable_names(Vars)]).
 
Is there such a write predicate or write option in SWI-Prolog?

If not, I suppose I could use write_term by first binding all variables in
a 'Name=Var'-list:

1)	Var = '$NAME'(Name) for each entry Name = Var in'Name=Var'-list 

2) 	define a portray hook for'$NAME'(Name) 
		user:portray($NAME'(Name)) :- 
			write_term(Name, [quoted(false)]).
3)	use write_term with portray(true)?

However I don't find this an elegant solutionn.

Jan, if there is no such write predicate in SWI-prolog yet, is it possible
to add such a complementary variable_names/1 option to the write_term/[2,3] 
predicate?

A minor remark on write_term in SWI-Prolog:

?- write_term(aap(P,Q,f(P)),[variable_names(['P'=P,'Q'=Q]),noot]).
aap(_G510, _G513, f(_G510))

P = _G510
Q = _G513 

There is no error message for an undefined option in
write_term[2,3] in SWI-Prolog(3.3.9).

Lourens

([email-masked])