From a543c2137e25931706eca97282541785b75660bf Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Wed, 30 Jun 2010 14:00:09 -0600 Subject: [PATCH] unstable: removed byte-counting-port.rkt (use open-output-nowhere instead) updated test to verify that open-output-nowhere has same behavior --- collects/compiler/zo-marshal.rkt | 4 ++-- .../tests/unstable/byte-counting-port.rkt | 6 +++--- collects/unstable/byte-counting-port.rkt | 21 ------------------- .../scribblings/byte-counting-port.scrbl | 15 ------------- collects/unstable/scribblings/unstable.scrbl | 1 - 5 files changed, 5 insertions(+), 42 deletions(-) delete mode 100644 collects/unstable/byte-counting-port.rkt delete mode 100644 collects/unstable/scribblings/byte-counting-port.scrbl diff --git a/collects/compiler/zo-marshal.rkt b/collects/compiler/zo-marshal.rkt index f3ee228f9d..fba002eecb 100644 --- a/collects/compiler/zo-marshal.rkt +++ b/collects/compiler/zo-marshal.rkt @@ -1,6 +1,6 @@ #lang scheme/base (require compiler/zo-structs - unstable/byte-counting-port + scheme/port scheme/match scheme/contract scheme/local @@ -68,7 +68,7 @@ (out-data (list* max-let-depth prefix (protect-quote form)) (make-out outp (lambda (v) (hash-ref shared v #f)) wrapped)) (values offsets post-shared (file-position outp))) - (define counting-p (make-byte-counting-port)) + (define counting-p (open-output-nowhere)) (define-values (offsets post-shared all-forms-length) (write-all counting-p)) (define all-short? (post-shared . < . #xFFFF)) diff --git a/collects/tests/unstable/byte-counting-port.rkt b/collects/tests/unstable/byte-counting-port.rkt index 92f122b54a..adbb3f0d5f 100644 --- a/collects/tests/unstable/byte-counting-port.rkt +++ b/collects/tests/unstable/byte-counting-port.rkt @@ -1,9 +1,9 @@ #lang racket -(require unstable/byte-counting-port +(require racket/port tests/eli-tester) (define name (gensym)) -(define cp (make-byte-counting-port name)) +(define cp (open-output-nowhere name)) (define (test-cp cp) (for/fold ([l 0]) ([i (in-range 100)]) @@ -15,4 +15,4 @@ (test (object-name cp) => name (test-cp cp) - (test-cp (make-byte-counting-port))) \ No newline at end of file + (test-cp (open-output-nowhere))) diff --git a/collects/unstable/byte-counting-port.rkt b/collects/unstable/byte-counting-port.rkt deleted file mode 100644 index 1902aa91cb..0000000000 --- a/collects/unstable/byte-counting-port.rkt +++ /dev/null @@ -1,21 +0,0 @@ -#lang racket - -(define (make-byte-counting-port [name 'byte-counting-port]) - (define location 0) - (define (write-out bs starting ending opt1 opt2) - (define how-many-written (- ending starting)) - (set! location (+ location how-many-written)) - how-many-written) - (define close void) - (define (get-location) - (values #f #f location)) - (make-output-port name always-evt write-out close - #f #f #f - get-location)) -;; Ryan: Isn't this just a reimplementation of 'open-output-nowhere'? -;; Actually, the 'get-location' method isn't called unless 'port-count-lines!' -;; is called first, and on a fresh port (no writes), it errors because it returns -;; 0 and a positive number is required. - -(provide/contract - [make-byte-counting-port (() (any/c) . ->* . output-port?)]) diff --git a/collects/unstable/scribblings/byte-counting-port.scrbl b/collects/unstable/scribblings/byte-counting-port.scrbl deleted file mode 100644 index 17047a6ae0..0000000000 --- a/collects/unstable/scribblings/byte-counting-port.scrbl +++ /dev/null @@ -1,15 +0,0 @@ -#lang scribble/manual -@(require "utils.rkt" (for-label racket unstable/byte-counting-port)) - -@title{Byte Counting Ports} - -@defmodule[unstable/byte-counting-port] - -@unstable[@author+email["Jay McCarthy" "jay@racket-lang.org"]] - -This library provides an output port constructor like @racket[open-output-nowhere], except it counts how many bytes have been written (available through @racket[file-position].) - -@defproc[(make-byte-counting-port [name any/c 'byte-counting-port]) - output-port?]{ -Creates and returns an output port that discards all output sent to it (without blocking.) The @racket[name] argument is used as the port's name. The total number bytes written is available through @racket[file-position].} - \ No newline at end of file diff --git a/collects/unstable/scribblings/unstable.scrbl b/collects/unstable/scribblings/unstable.scrbl index d179bd24cd..92063f9477 100644 --- a/collects/unstable/scribblings/unstable.scrbl +++ b/collects/unstable/scribblings/unstable.scrbl @@ -113,7 +113,6 @@ Keep documentation and tests up to date. @include-section["generics.scrbl"] @include-section["markparam.scrbl"] @include-section["debug.scrbl"] -@include-section["byte-counting-port.scrbl"] @;{--------}