Changes between Version 2 and Version 3 of DesignOfStreams


Ignore:
Timestamp:
01/27/10 21:21:12 (12 years ago)
Author:
vvoutilainen
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DesignOfStreams

    v2 v3  
    11= Design of lisp streams in ABCL =
    22
    3 == The current design ==
    4 === The problem with the current design ===
     3== The previous design ==
     4
     5Previously, ABCL streams were built-in classes. This presented some problems for Gray streams,
     6because ABCL CLOS can't use a built-in class as a base class, and Gray streams derive from
     7a system-stream class. This was corrected by converting ABCL streams to be structure-objects
     8instead of built-in classes, allowing CLOS to derive from the streams. There was, however, another
     9problem that revealed a need to change the design in more drastic ways.
     10
     11=== The problem with the previous design ===
     12
     13While converting the streams from built-in classes to structure-objects allowed derivation,
     14the pretty printer still didn't work with Gray streams. Gray streams replace the system stream
     15functions, saving the old function symbols so that they can be later invoked. The pretty printer,
     16however, just replaces the stream functions, and calls the low-level primitives directly, thus
     17bypassing Gray streams completely. The attached image portrays the problem, where pprint will,
     18for example, invoke %stream-write-char, thus bypassing any methods that there may be for
     19stream-write-char using Gray streams.
    520
    621[[Image(pprint-problem.png)]]
    722
    823
    9 == The planned future design ==
     24== The planned future design and solution to the problem ==
     25
     26The solution to the problem is quite similar to how SBCL does its streams. First of all, the pretty printer will
     27no longer replace stream functions. The stream functionality will be based on closures in the slots of
     28the structure-object representing the stream, and those closures will invoke low-level i/o functions that
     29are stream-specific. The pretty printer will just setup closures that will extract the underlying stream
     30object from a pprint-wrapped stream, and invoke its low-level functions. If pprint wrapping isn't present,
     31the closures will contain closures that directly invoke low-level functions of streams. Gray streams will
     32still replace the stream functions, because it's capable of invoking the replaced functions.
    1033
    1134[[Image(pprint-solution.png)]]