close Warning: Can't synchronize with repository "(default)" ("(default)" is not readable or not a Git repository.). Look in the Trac log for more information.

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#101 closed defect (fixed)

Gray steam non-conformance: not invoking STREAM-CLEAR-OUTPUT and STREAM-ADVANCE-TO-COLUMN

Reported by: Anton Vodonosov Owned by: Raymond Toy
Priority: minor Milestone:
Component: Gray-streams Version: 2014-05
Keywords: Cc:

Description

As we can see from the trivial-gray-streams test suite:

http://cl-test-grid.appspot.com/blob?key=eefx5t0o0r https://github.com/trivial-gray-streams/trivial-gray-streams/blob/master/test/test.lisp

CMUCL does not call some generic functions when necessary:

  1. When we call cl:clear-output for a gray stream, CMUCL calls ext:stream-force-output instead of ext:stream-clear-output
  1. When we call cl:format with the ~T directive, for example (cl:format a-gray-stream "~10,t"), CMUCL calls ext:stream-line-column and ext:stream-write-string instead of ext:stream-advance-to-column

See the specification: http://www.nhplace.com/kent/CL/Issues/stream-definition-by-user.html

STREAM-ADVANCE-TO-COLUMN stream column [Generic Function]

Writes enough blank space so that the next character will be written at the specified column. Returns true if the operation is successful, or NIL if it is not supported for this stream. This is intended for use by by PPRINT and FORMAT ~T. The default method uses STREAM-LINE-COLUMN and repeated calls to STREAM-WRITE-CHAR with a #\SPACE character; it returns NIL if STREAM-LINE-COLUMN returns NIL.

So, it is better to call ext:stream-advance-to-column, and provide the default implementation for ext:stream-advance-to-column, as specified.

Importance: I am unaware of a library that depend on those Gray protocol details. But it is non-conforming.

Change History (5)

comment:1 Changed 9 years ago by Anton Vodonosov

Component: CoreGray-streams
Owner: changed from somebody to Raymond Toy

comment:2 Changed 9 years ago by Anton Vodonosov

Priority: majorminor

comment:3 Changed 9 years ago by toy.raymond@…

Resolution: fixed
Status: newclosed

commit e585e8d6acbc146e978d1c2c5171987b6ba2fddf Author: Raymond Toy <toy.raymond@…> Date: Sat Aug 9 23:49:14 2014 -0700

Fix ticket:101, implementing STREAM-ADVANCE-TO-COLUMN for FORMAT ~T.

  • code/format.lisp:
    • Add support for Gray streams for tabulation, calling STREAM-ADVANCE-TO-COLUMN as needed.
  • tests/gray-stream.lisp:
    • Add tests for absolute and relative tabulation. These are simple and just compare that lisp streams and Gray streams produce the same output.
  • general-info/release-20f.txt:
    • Update.

comment:4 Changed 9 years ago by Raymond Toy

I'm not sure, but I think the trivial-gray-streams test for STREAM-ADVANCE-TO-COLUMN might still fail because the implementation still calls STREAM-LINE-COLUMN and STREAM-WRITE-CHAR.

I did test that (format <gray> "~10T") does call STREAM-ADVANCE-TO-COLUMN using TRACE.

comment:5 Changed 9 years ago by Anton Vodonosov

The test will succeed if STREAM-ADVANCE-TO-COLUMN is called, no matter what other methods are called too.

Note: See TracTickets for help on using tickets.