From 7ef56fbfc5908e33a995b27dc447654751fd8781 Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Sat, 17 Dec 2011 22:49:44 -0700 Subject: [PATCH] pruned unstable/string (moved some code back to web-server) --- collects/unstable/scribblings/string.scrbl | 17 ---------- collects/unstable/string.rkt | 36 +------------------- collects/web-server/private/util.rkt | 39 ++++++++++++++++++++-- 3 files changed, 37 insertions(+), 55 deletions(-) diff --git a/collects/unstable/scribblings/string.scrbl b/collects/unstable/scribblings/string.scrbl index f6c76c0d79..493aa51242 100644 --- a/collects/unstable/scribblings/string.scrbl +++ b/collects/unstable/scribblings/string.scrbl @@ -3,7 +3,6 @@ scribble/manual "utils.rkt" (for-label unstable/string - racket/serialize racket/contract racket/base)) @@ -13,22 +12,6 @@ @unstable-header[] -@defproc[(lowercase-symbol! [sb (or/c string? bytes?)]) - symbol?]{ - Returns @racket[sb] as a lowercase symbol. -} - -@defproc[(read/string [s string?]) - serializable?]{ - @racket[read]s a value from @racket[s] and returns it. -} - -@defproc[(write/string [v serializable?]) - string?]{ - @racket[write]s @racket[v] to a string and returns it. -} - - @addition{Vincent St-Amour} @defproc[(regexp-filter [pattern (or/c string? bytes? regexp? byte-regexp?)] diff --git a/collects/unstable/string.rkt b/collects/unstable/string.rkt index 1f80ff3930..935d200e68 100644 --- a/collects/unstable/string.rkt +++ b/collects/unstable/string.rkt @@ -1,39 +1,5 @@ #lang racket/base -(require racket/contract/base - racket/serialize) - -(define (read/string str) - (define r (read (open-input-string str))) - (cond [(eof-object? r) (raise-type-error 'read/string "nonempty string" str)] - [else r])) - -;; Eli: Same comments as `read/bytes'. - -(define (write/string v) - (define str (open-output-string)) - (write v str) - (get-output-string str)) -;; Eli: Same comments as `write/string', and worse -- this is the same as -;; (format "~s" v) - -; lowercase-symbol! : (or/c string bytes) -> symbol -(define (lowercase-symbol! s) - (string->symbol - (string-downcase - (if (bytes? s) - (bytes->string/utf-8 s) - s)))) -;; Eli: This doesn't make any sense at all. Why is the `!' in the name? Why -;; does it accept bytes? Why does a function in a "string" library accept -;; bytes? How can I guess that this creates a new symbol from that name? -;; (Which makes me think that this is (compose string->symbol string-downcase -;; symbol->string)) - -(provide/contract - [lowercase-symbol! ((or/c string? bytes?) . -> . symbol?)] - [read/string (string? . -> . serializable?)] - [write/string (serializable? . -> . string?)]) - +(require racket/contract/base) ;; added by stamourv diff --git a/collects/web-server/private/util.rkt b/collects/web-server/private/util.rkt index 392a3af883..e733f2b4f2 100644 --- a/collects/web-server/private/util.rkt +++ b/collects/web-server/private/util.rkt @@ -1,18 +1,17 @@ #lang racket/base (require racket/contract/base unstable/list - unstable/contract) + unstable/contract + racket/serialize) (require unstable/bytes unstable/contract unstable/list - unstable/string unstable/net/url) (provide (all-from-out unstable/bytes unstable/contract unstable/list - unstable/string unstable/net/url)) ;; -- @@ -111,3 +110,37 @@ [strip-prefix-ups ((listof path-piece?) . -> . (listof path-piece?))] [directory-part (path-string? . -> . path?)] [build-path-unless-absolute (path-string? path-string? . -> . path?)]) + +;; -- + +(define (read/string str) + (define r (read (open-input-string str))) + (cond [(eof-object? r) (raise-type-error 'read/string "nonempty string" str)] + [else r])) + +;; Eli: Same comments as `read/bytes'. + +(define (write/string v) + (define str (open-output-string)) + (write v str) + (get-output-string str)) +;; Eli: Same comments as `write/string', and worse -- this is the same as +;; (format "~s" v) + +; lowercase-symbol! : (or/c string bytes) -> symbol +(define (lowercase-symbol! s) + (string->symbol + (string-downcase + (if (bytes? s) + (bytes->string/utf-8 s) + s)))) +;; Eli: This doesn't make any sense at all. Why is the `!' in the name? Why +;; does it accept bytes? Why does a function in a "string" library accept +;; bytes? How can I guess that this creates a new symbol from that name? +;; (Which makes me think that this is (compose string->symbol string-downcase +;; symbol->string)) + +(provide/contract + [lowercase-symbol! ((or/c string? bytes?) . -> . symbol?)] + [read/string (string? . -> . serializable?)] + [write/string (serializable? . -> . string?)])