This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Change in printing of Scheme values


Just a note in a change to how Kawa writes values to output ports.
Note that this is an incompatible change, and differs from R5RS
and most Scheme implementations, but I think it is an improvement.

The change is that if two "word" values are written in a row, a space
is written between them.  A word is most Scheme values, including
numbers and lists.  A Scheme string is treated as a word by write,
but not by display.

Examples:
#|kawa:1|# (values 3 4 5)
3 4 5
#|kawa:2|# (display 3)(display 4) (display 5)
3 4 5
#|kawa:4|# (display (values 1 2)) (display (values 3 4))
1 2 3 4

However, spaces are not added before or after strings:

#|kawa:7|# (values 3 "+" 4 "=" (+ 3 4))
3+4=7

unless you're using write:

#|kawa:8|# (write 4) (write "+") (write 4)
4 "+" 4

Scheme symbols are treated as words:
#|kawa:15|# (display 'a) (display 'b)
a b
I think this is the right thing to do, but it means that spaces
are written between Java strings.  (This may change if/when we
change the Kawa representation of strings and symbols, as
discussed before.)

The result of format does not add a space, whether formatting to a
string or to a file:

#|kawa:13|# (display 4) (format #t "The value is ~d" 5) (display 6)
4The value is 56
#|kawa:14|# (display 4) (format #f "The value is ~d" 5) (display 6)
4The value is 56

Hopefully, very little code will break.  As I said, I think it is worth
it.  (This change is partly for the sake of XQuery, but I think it is
also a win for Scheme.)

This of course applies only to the SVN version, for now.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]