From 4c947f188dd2701ccca7a8dc2c8146647c9eba57 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 8 Apr 2014 11:24:40 -0600 Subject: [PATCH] reduce `racket/undefined` to just `undefined` --- pkgs/htdp-pkgs/htdp-lib/lang/private/teach.rkt | 2 +- pkgs/pconvert-lib/mzlib/pconvert.rkt | 2 +- pkgs/plai/datatype.rkt | 3 +++ .../racket-doc/scribblings/reference/undefined.scrbl | 9 ++------- .../scribblings/reference/unsafe-undefined.scrbl | 12 +++--------- .../typed-racket-lib/typed-racket/types/abbrev.rkt | 5 +++-- .../typed-racket-lib/typed-racket/utils/any-wrap.rkt | 2 +- racket/collects/racket/undefined.rkt | 5 +---- racket/collects/racket/unsafe/undefined.rkt | 3 --- 9 files changed, 15 insertions(+), 28 deletions(-) diff --git a/pkgs/htdp-pkgs/htdp-lib/lang/private/teach.rkt b/pkgs/htdp-pkgs/htdp-lib/lang/private/teach.rkt index fd95907105..8effa965f5 100644 --- a/pkgs/htdp-pkgs/htdp-lib/lang/private/teach.rkt +++ b/pkgs/htdp-pkgs/htdp-lib/lang/private/teach.rkt @@ -89,7 +89,7 @@ ;; Wrapped around uses of local-bound variables: (define (teach-check-not-undefined name val) - (if (undefined? val) + (if (eq? undefined val) (raise (make-exn:fail:contract:variable (format "local variable used before its definition: ~a" name) diff --git a/pkgs/pconvert-lib/mzlib/pconvert.rkt b/pkgs/pconvert-lib/mzlib/pconvert.rkt index a2f932e2a3..36340486f7 100644 --- a/pkgs/pconvert-lib/mzlib/pconvert.rkt +++ b/pkgs/pconvert-lib/mzlib/pconvert.rkt @@ -124,7 +124,7 @@ (null? expr) ;; # test - yuck, and maybe not worth checking ;; anymore, since undefined generally shouldn't escape - (undefined? expr) + (eq? undefined expr) ) 'atomic] [(and (not (struct? expr)) ;; struct names are the wrong thing, here diff --git a/pkgs/plai/datatype.rkt b/pkgs/plai/datatype.rkt index 84090fc450..303a82829f 100644 --- a/pkgs/plai/datatype.rkt +++ b/pkgs/plai/datatype.rkt @@ -87,6 +87,9 @@ stx)] [_ (transfer-srcloc orig stx)])))) +(define (undefined? x) + (eq? undefined x)) + (define-syntax (define-type stx) (syntax-parse stx diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/reference/undefined.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/reference/undefined.scrbl index 8f313bd027..67ff607fce 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/reference/undefined.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/reference/undefined.scrbl @@ -4,7 +4,7 @@ @title[#:tag "undefined"]{Undefined} -@note-lib[racket/undefined] +@note-lib-only[racket/undefined] The constant @racket[undefined] can be used as a placeholder value for a value to be installed later, especially for cases where premature @@ -15,9 +15,4 @@ The @racket[undefined] value is always @racket[eq?] to itself. @history[#:added "6.0.0.6"] -@defproc[(undefined? [v any/c]) boolean?]{ - -Returns @racket[#t] if @racket[v] is the constant @racket[undefined], -@racket[#f] otherwise.} - -@defthing[undefined undefined?]{The ``undefined'' constant.} +@defthing[undefined any/c]{The ``undefined'' constant.} diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/reference/unsafe-undefined.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/reference/unsafe-undefined.scrbl index 6fd6027b25..81e4e19028 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/reference/unsafe-undefined.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/reference/unsafe-undefined.scrbl @@ -4,7 +4,7 @@ @title[#:tag "unsafe-undefined"]{Unsafe Undefined} -@note-lib[racket/unsafe/undefined] +@note-lib-only[racket/unsafe/undefined] The constant @racket[unsafe-undefined] is used internally as a placeholder value. For example, it is used by @racket[letrec] as a @@ -20,19 +20,13 @@ The @racket[unsafe-undefined] value is always @racket[eq?] to itself. @history[#:added "6.0.0.6"] -@defproc[(unsafe-undefined? [v any/c]) boolean?]{ - -Returns @racket[#t] if @racket[v] is the constant -@racket[unsafe-undefined], @racket[#f] otherwise.} - - -@defthing[unsafe-undefined unsafe-undefined?]{ +@defthing[unsafe-undefined any/c]{ The unsafe ``undefined'' constant.} @defproc[(check-not-unsafe-undefined [v any/c] [sym symbol?]) - (and/c any/c (not/c unsafe-undefined?))]{ + (and/c any/c (not/c (one-of/c unsafe-undefined)))]{ Checks whether @racket[v] is @racket[unsafe-undefined], and raises @racket[exn:fail:contract:variable] in that case with an error message diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/abbrev.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/abbrev.rkt index 258d0983ea..2f5c8e591a 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/abbrev.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/abbrev.rkt @@ -25,6 +25,7 @@ (for-template racket/base racket/contract/base + racket/undefined (only-in racket/pretty pretty-print-style-table?) (only-in racket/udp udp?) (only-in racket/tcp tcp-listener?) @@ -92,8 +93,8 @@ (define/decl -Boolean (Un -False -True)) (define/decl -Undefined (make-Base 'Undefined - #'undefined? ; initial value of letrec bindings - undefined?)) + #'(lambda (x) (eq? x undefined)) + (lambda (x) (eq? x undefined)))) (define/decl -Bytes (make-Base 'Bytes #'bytes? bytes?)) (define/decl -Base-Regexp (make-Base 'Base-Regexp #'(and/c regexp? (not/c pregexp?)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/utils/any-wrap.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/utils/any-wrap.rkt index 18d9c29dcf..887bfb11ae 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/utils/any-wrap.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/utils/any-wrap.rkt @@ -10,7 +10,7 @@ (define (base-val? e) (or (number? e) (string? e) (char? e) (symbol? e) - (null? e) (regexp? e) (undefined? e) (path? e) + (null? e) (regexp? e) (eq? undefined e) (path? e) (regexp? e) (keyword? e) (bytes? e) (boolean? e) (void? e) ;; Base values because you can only store flonums/fixnums in these ;; and not any higher-order values. This isn't sound if we ever diff --git a/racket/collects/racket/undefined.rkt b/racket/collects/racket/undefined.rkt index a193bbaca3..858dbb23ea 100644 --- a/racket/collects/racket/undefined.rkt +++ b/racket/collects/racket/undefined.rkt @@ -1,10 +1,7 @@ #lang racket/base -(provide undefined - undefined?) +(provide undefined) (define-values (struct:undef make-undef undef? undef-ref undef-set!) (make-struct-type 'undefined #f 0 0)) (define undefined (make-undef)) - -(define (undefined? v) (eq? v undefined)) diff --git a/racket/collects/racket/unsafe/undefined.rkt b/racket/collects/racket/unsafe/undefined.rkt index 94fc7e6746..7ea9fe11ed 100644 --- a/racket/collects/racket/unsafe/undefined.rkt +++ b/racket/collects/racket/unsafe/undefined.rkt @@ -3,7 +3,4 @@ (provide check-not-unsafe-undefined unsafe-undefined - unsafe-undefined? prop:chaperone-unsafe-undefined) - -(define (unsafe-undefined? v) (eq? v unsafe-undefined))