[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [net%TUB.BITNET: Questions]



   From: Chris Hanson <cph%kleph.ai.mit.edu@RELAY.CS.NET>
   To: net%TUB.BITNET@MITVMA.MIT.EDU
   Cc: rrrs-authors@mc.lcs.mit.edu
   Subject: [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?
   
   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.

There is a more important reason related to the fact that "display" is a
generic operation.  Character objects are not guaranteed to be distinct
from other objects, although they are in some implementations.  So, for
example, it is possible to represent them as a range of integers or as
unit-length strings.  Since display will always choose to print integers
as integers and strings as strings, the procedure "write-char" is needed
to force a character so represented to be treated as a character.