Re: Printing key:value terms

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Wed 15 Dec 2004 11:24:12 AM GMT
Message-ID: <41C01EDC.3000905@icparc.ic.ac.uk>
Jacco van Ossenbruggen wrote:
> In eclipse,
> 
> X=a:b, write(X).
> 
> prints a : b (note the spaces), while, e.g. SWI Prolog prints a:b, 
> (without spaces).
> 
> How can I tell eclipse to print the term without spaces?

The forthcoming release 5.8 has new print-options for write_term and
printf to control this:

Version 5.8 #76, Tue Dec 14 00:08 2004
[eclipse 1]: write_term(a:b, [compact(true)]).
a:b
Yes (0.00s cpu)

[eclipse 2]: printf("%w  %Kw", [a:b,a:b]).
a : b  a:b
Yes (0.00s cpu)

or you can set the option for all output to a particular stream:

[eclipse 5]: set_stream_property(output, output_options, [compact(true)]).
Yes (0.00s cpu)

[eclipse 6]: writeln(a:b).
a:b


Release 5.8 will be out this week, you can already get a prerelease from the
web site.

In older releases, you can set

Version 5.7 #25, Sun Dec 14 03:24 2003
[eclipse 1]: set_flag(syntax_option, dense_output).

Yes (0.00s cpu)
[eclipse 2]: writeln(a:b).
a:b

The effect of this flag setting is module-local.


> 
> I tried the portray function,

portray only transforms terms into other terms, so it cannot be used
to control the exact printing format.


 > but local portay(:/2 , tr/2, []) yields a
> syntax error:
> 
> syntax error: unexpected token
> | :- local portray(:/2, p/2,[]).
> |                    ^ here

You need a space between : and / otherwise they get parsed as
a single ';/' token.  Or you can parenthesise the (:).


-- 
  Joachim Schimpf              /             phone: +44 20 7594 8187
  IC-Parc                     /      mailto:J.Schimpf@imperial.ac.uk
  Imperial College London    /    http://www.icparc.ic.ac.uk/eclipse
Received on Wed Dec 15 11:25:54 2004

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:32 PM GMT GMT