[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[net%TUB.BITNET: Questions]
Date: Mon, 23 Nov 87 19:28:38 +0100
From: Oliver Laumann <net%TUB.BITNET at MITVMA.MIT.EDU>
I'll answer your second question and leave the first for someone else.
2) What is the exact difference between (write-char <char>) and
(display <char>)? "write-char" seems to be redundant. Is "display"
supposed to terminate its output by a space or newline or something
like this?
There are two reasons for this. First is the historical development
of the standard. Originally, when `display' was defined, its action
on characters was defined to be the same as `write'. So at that time
`write-char' was not redundant. Later `display' was changed to treat
characters specially, creating the redundancy.
Second, `display' is a generic operation, in the sense that it will
print any object. It recursively prints compound structures, treating
any imbedded strings and characters specially. Because of this, it is
a moderately expensive operation to perform, since it potentially will
have to do quite a bit of work. On the other hand, `write-char' is a
very simple operation, in fact the simplest output operation (all of
the other output procedures could be defined in terms of it). Because
of this it can be very efficiently implemented.
Finally, there is my own personal bias -- MIT Scheme has a
non-standard output procedure called `write-string', which accepts a
single string argument and prints it exactly as `display' would.
Using `write-char', `write-string', and `write', I've found that I
never need to use `display'. This is because all of the instances
where I would have used `display', I actually mean `write-string', so
I use the latter instead.