=.. displays incorrectly with ops, needs option to display correctly

On Windows 10

Welcome to SWI-Prolog (threaded, 64 bits, version 9.1.14-41-g41ac4a569)

?- Op=mod,A='100',B=a,Expr =.. [Op,A,B].
Op = (mod),
A = '100',
B = a,
Expr = '100'mod a.

Was expecting Expr = mod('100',a).

This worked as expected.

?- Op='division',A='100',B=a,Expr =.. [Op,A,B].
Op = division,
A = '100',
B = a,
Expr = division('100', a).

but this did not

?- Op='div',A='100',B=a,Expr =.. [Op,A,B].
Op = (div),
A = '100',
B = a,
Expr = '100'div a.

Currently upgrading SWI-Prolog to latest version, will retest and post.


With recent install of SWI-Prolog

Welcome to SWI-Prolog (threaded, 64 bits, version 9.1.20)

?- Op=mod,A='100',B=a,Expr =.. [Op,A,B].
Op = (mod),
A = '100',
B = a,
Expr = '100'mod a.

?- Op='division',A='100',B=a,Expr =.. [Op,A,B].
Op = division,
A = '100',
B = a,
Expr = division('100', a).

?- Op='div',A='100',B=a,Expr =.. [Op,A,B].
Op = (div),
A = '100',
B = a,
Expr = '100'div a.

As a workaround using

?- Op=mod,A='100',B=a,Expr =.. [op,Op,A,B].
Op = (mod),
A = '100',
B = a,
Expr = op(mod, '100', a).

That’s because mod can be used simliar to some other mathematical operators where it’s an infix operator…
e.g. if you used ‘+’ as the operator, it would display similarly.

If you want it displayed differnently at the top level you can use ignore_ops=true in the answer_write_options .e.g.

?- set_prolog_flag(answer_write_options, [quoted(true), portray(true), max_depth(10), attributes(portray), ignore_ops(true)]).
true.

?- Op=mod,A='100',B=a,Expr =.. [Op,A,B].
Op =  (mod),
A = '100',
B = a,
Expr = mod('100',a).
1 Like