Re: disappearing spaces problem
From: Patrick Herring (ph_at_anweald.co.uk)
Date: 10/03/04
- Next message: student: "Re: User-question"
- Previous message: Remko Troncon: "comp.lang.prolog Frequently Asked Questions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 02 Oct 2004 22:08:49 GMT
Jan Wielemaker <jan@ct.xs4all.nl> wrote:
| In article <413ef91e.7691366@usenet.plus.net>, Patrick Herring wrote:
| > Here's a problem I'm having in SWI but have also had with LPA (DOS)
| > and Sicstus and have never understood let alone solved:
| >
| > If I do op( 0500, yfy, and).
| > then write( a and b )
| > gives a and b
| > but if I do op( 0500, yfy, & )
| > then write( a & b )
| > gives a&b
| > where the spaces either side of the & have gone. I also get this with
| > pseudo-random other user-defined ops.
| >
| > I've always assumed it was down to operator precedence but the above
| > example shows that's not necessarily it. Any clues?
|
| In most Prolog systems write/1 inserts minimal spaces, brackets, etc.
| write(a and b) cannot be written as `aandb' as this is a totally
| different term. `a & b' and `a&b' however read back to the same term.
| I.e. between characters of different class there is no extra space,
| but if the characters would glue together as a single token a space is
| inserted. I'm not sure whether or not the ISO standard forces some
| standard space handling on Prolog systems.
|
| `Solve'? If you want a particular output you've got to rol your
| own. Prolog simply writes terms using Prolog syntax. write/1 is
| actually a weird predicate as it doesn't insert quotes and therefore
| there is no quarantee it is a correct Prolog term. Using it for
| printing the content of an atom without quotes is just about the
| only sensible use: write('Hello World!').
Just got round to trying this out. My understanding of Prolog has
improved by one whole leap slash bound. Thanks!
I suspect I've been spoilt by languages which tend to treat anything
in characters as a physical object, like typewriters and malloc
routines do.
-- Patrick Herring, Sheffield, UK http://www.anweald.co.uk
- Next message: student: "Re: User-question"
- Previous message: Remko Troncon: "comp.lang.prolog Frequently Asked Questions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|