dkahn@SCHUBERT.PRODIGY.CS.CMU.EDU (Daniel Kahn) (03/13/91)
The format function in CL take a string with a fill pointer and will push the additional characters onto the end of the string. Is it an omission from CLtL 2nd addition that the string must also be created created with an :adjustable t keyword value pair? If you don't do this then it isn't clear that the vector-push-extend that format calls will create a new vector EQ to the one passed in as an argument. If the result isn't EQ to the old value then I don't see how you can get your result. --dan
barmar@think.com (Barry Margolin) (03/15/91)
In article <1991Mar13.021632.26061@cs.cmu.edu> dkahn@SCHUBERT.PRODIGY.CS.CMU.EDU (Daniel Kahn) writes: >Is it an omission from CLtL 2nd addition that the string must also be created >created with an :adjustable t keyword value pair? It says that it adds the characters as if by VECTOR-PUSH-EXTEND, so any restrictions on the latter function are also applicable to FORMAT. > If you don't do this then it >isn't clear that the vector-push-extend that format calls will create a new >vector EQ to the one passed in as an argument. If the result isn't EQ to the old >value then I don't see how you can get your result. What non-EQ result? VECTOR-PUSH-EXTEND is required to signal an error if it needs to grow the vector and it isn't adjustable. Note that the vector only has to be adjustable if you need to grow it. If (array-dimension vector 0) => 100 and (fill-pointer vector) => 50 then you can call VECTOR-PUSH-EXTEND 50 times without error, even if the array isn't adjustable. As a consequence, the following is valid: (let ((string (make-array 10 :fill-pointer 0 :element-type 'character))) (format string "Testing") string) There is room for 10 characters before it needs to adjust the array, but it only pushes 7 characters so it is OK. -- Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar