reduce racket/undefined
to just undefined
This commit is contained in:
parent
60a1b78070
commit
4c947f188d
|
@ -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)
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
(null? expr)
|
||||
;; #<undefined> 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
|
||||
|
|
|
@ -87,6 +87,9 @@
|
|||
stx)]
|
||||
[_ (transfer-srcloc orig stx)]))))
|
||||
|
||||
(define (undefined? x)
|
||||
(eq? undefined x))
|
||||
|
||||
(define-syntax (define-type stx)
|
||||
(syntax-parse
|
||||
stx
|
||||
|
|
|
@ -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.}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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?))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue
Block a user