From 83a573ccd8b216d9600435692dfa4da851a55d91 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 8 Apr 2014 10:22:15 -0600 Subject: [PATCH] racket/undefined: remove `undefined?` and `check-not-undefined` The intent is to provide a minimal bridge between the current Racket and one where `(letrec ([x x]) x)` no longer works. Merge to v6.0.1 --- .../scribblings/reference/data.scrbl | 26 ++++++------------- racket/collects/racket/undefined.rkt | 15 +---------- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/pkgs/racket-pkgs/racket-doc/scribblings/reference/data.scrbl b/pkgs/racket-pkgs/racket-doc/scribblings/reference/data.scrbl index 2ca572bd96..e0cf7bf794 100644 --- a/pkgs/racket-pkgs/racket-doc/scribblings/reference/data.scrbl +++ b/pkgs/racket-pkgs/racket-doc/scribblings/reference/data.scrbl @@ -1,5 +1,6 @@ #lang scribble/doc -@(require "mz.rkt") +@(require "mz.rkt" + (for-label racket/undefined)) @title[#:style 'toc #:tag "data"]{Datatypes} @@ -174,25 +175,14 @@ The @|void-const| value is always @racket[eq?] to itself. @section[#:tag "undefined"]{Undefined} The constant @|undefined-const| is used as the initial value for -@racket[letrec] bindings. +@racket[letrec] bindings and in other places where a placeholder value +is needed before a specific value can be assigned. Use +@racket[undefined] (which is bound to @|undefined-const|) as a last resort. The @|undefined-const| value is always @racket[eq?] to itself. -@note-lib[racket/undefined] +@note-lib-only[racket/undefined] + +@defthing[undefined any/c]{The @|undefined-const| constant.} @history[#:added "6.0.0.6"] - -@defproc[(undefined? [v any/c]) boolean?]{Returns @racket[#t] if @racket[v] is the - constant @|undefined-const|, @racket[#f] otherwise.} - - -@defthing[undefined undefined?]{The @|undefined-const| constant.} - -@defproc[(check-not-undefined [v any/c] [sym symbol?]) (and/c any/c (not/c undefined?))]{ - -Checks whether @racket[v] is @|undefined-const|, and raises -@racket[exn:fail:contract:variable] in that case with an error message -along the lines of ``@racket[sym]: variable used before its definition.'' -If @racket[v] is not @|undefined-const|, then @racket[v] is returned. - -} diff --git a/racket/collects/racket/undefined.rkt b/racket/collects/racket/undefined.rkt index e8eea020cf..29252b11b5 100644 --- a/racket/collects/racket/undefined.rkt +++ b/racket/collects/racket/undefined.rkt @@ -1,21 +1,8 @@ #lang racket/base -(require '#%kernel) -(provide check-not-undefined - undefined - undefined?) +(provide undefined) ;; In a future version of Racket, this `letrec` pattern ;; will not work, but the `racket/undefined` library will ;; still export an `undefined`: (define undefined (letrec ([x x]) x)) - -(define (undefined? v) (eq? v undefined)) -(define (check-not-undefined v s) - (unless (symbol? s) (raise-argument-error 'check-not-undefined "symbol?" 1 v s)) - (if (eq? v undefined) - (raise (make-exn:fail:contract:variable - (format "~a: variable used before its definition" s) - (current-continuation-marks) - s)) - v))