[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Issue: STREAM-INFO (Version 4)
- To: email@example.com
- Subject: Issue: STREAM-INFO (Version 4)
- From: firstname.lastname@example.org (Richard C. Waters)
- Date: Thu, 30 Jun 88 14:47:06 EDT
- Cc: email@example.com, CL-Cleanup@sail.stanford.edu
- In-reply-to: firstname.lastname@example.org's message of 29 Jun 88 23:32:43 PDT <880629-233315-4002@Xerox>
How 'bout just making it explicit that these things are intentionally left
undefined, with some of the reasons you gave?
I'm a little leary of adding a function where the requirements on
the output values are not spelled out. Is the width of "froboznick"
guaranteed to be the sum of the widths of "frob" and "oznick"?
Greater than the width of "frob"? Of "foo"? What about kerning?
I think that there are some very specific things that we can say. The
key thing is that we have to make it clear exactly what is being
specified. In particular, the actual numerical values are
implementation specific and do not matter much. However, there are
several key RELATIVE properties which are the whole point.
In the following, suppose that N is a positive integer, X and Y are
strings, and S is a stream that fully supports all four functions
OUTPUT-WIDTH, OUTPUT-POSITION, STRING-WIDTH, OUTPUT-SPACE; i.e., NIL is
never returned when any of these functions is called on S.
First, there are three minimal properties of OUTPUT-POSITION.
(1) (NOT (MINUSP (OUTPUT-POSITION S)))
(2) (ZEROP (OUTPUT-POSITION (PROGN (TERPRI S) S)))
(3) If something is at an output position of N on one line, and
something else is at an output position of N on another line, and
assuming that wraparound truncation etc. have not occured on either
line (see (5) below), then the two things are lined up vertically one
under the other.
Second, there are two properties that define
STRING-WIDTH and OUTPUT-SPACE in terms of OUTPUT-POSITION.
(3) (= (+ (OUTPUT-POSITION S) (STRING-WIDTH X S))
(OUTPUT-POSITION (PROGN (WRITE-STRING X S) S)))
(4) (= (+ (OUTPUT-POSITION S) N)
(OUTPUT-POSITION (PROGN (OUTPUT-SPACE N S) S)))
and OUTPUT-SPACE has no effect on S other than introducing blank space
that changes the output position.
For the following properties it must be assumed that X and Y consist
solely of standard characters as defined on CLTL pp20-21 and that X
and Y do not contain any #\newline characters.
The following property defines the meaning of OUTPUT-WIDTH.
(5) Assuming that one has just done (TERPRI S),
If (< (STRING-WIDTH X S) (OUTPUT-WIDTH S))
then (WRITE-STRING X S) is guaranteed to output the string on one line
without any truncation or wraparound.
[If the condition above is not satisfied, then the exact result of
the output is not specified. However, It is assumed that each
implementation will do something reasonable, e.g., use wraparound. It
might also be the case that the output width was pessimistic and that
the string might fit on the end of the line. The point of
OUTPUT-WIDTH is that it returns a guaranteed safe width.]
This property must hold no matter what characters are in X as long
as none of these characters cause a reduction in output position.
I.e., it is alright for X to contain tabs and many other weird
characters, but the property may be violated if X contains newlines or
(6) (= (STRING-WIDTH (CONCATENATE 'STRING X Y) S)
(+ (STRING-WIDTH X S) (STRING-WIDTH Y S)))
This property is violated for many kinds of nonstandard characters,
notably tabs and newlines. It could also fail if the strings had
ligatures or font change characters or other wierd things.
Nevertheless, this property is very useful. The efficiency of my
pretty printer is significantly improved by assuming that this
PS I agree with KMPs basic comment that although this is indeed a
fuzzy area, it is better to get information which may in many
situations only be approximate than not to be able to get any
information at all.