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

with-output-to-string query

    The definition of WITH-OUTPUT-TO-STRING given in the Common Lisp 
    reference manual states that:

    "If string is specified ... the output is incrementally appended to the 
     string, as if using VECTOR-PUSH-EXTEND if the string is adjustable, and
     otherwise as if using VECTOR-PUSH."

    This implies that after a non-adjustable output string is "filled" any
    extra characters output to it will simply be dropped and no error will
    be signalled.  Is this correct?

Yeah, given that VECTOR-PUSH is documented not to complain when a
non-adjustable string overflows, it seems to follow that
WITH-OUTPUT-TO-STRING should just ignore excess output in this case and
not signal an error.  This seems like a treacherous mechanism that could
screw the unwary, but in the vast majoirty of cases users will let the
system create the string or will use an adjustable one if this meant to
implement some sort of non-consing buffer.

I'm not sure why we decided that VECTOR-PUSH should fail silently, but
we must have had some good reason at the time.  Probably we just copied
Zetalisp and THEY had a good reason.

-- Scott