On this page:
17.1 Unsafe Numeric Operations
unsafe-fx+
unsafe-fx-
unsafe-fx*
unsafe-fxquotient
unsafe-fxremainder
unsafe-fxmodulo
unsafe-fxabs
unsafe-fxand
unsafe-fxior
unsafe-fxxor
unsafe-fxnot
unsafe-fxlshift
unsafe-fxrshift
unsafe-fxrshift/  logical
unsafe-fxpopcount
unsafe-fxpopcount32
unsafe-fxpopcount16
unsafe-fx+  /  wraparound
unsafe-fx-/  wraparound
unsafe-fx*/  wraparound
unsafe-fxlshift/  wraparound
unsafe-fx=
unsafe-fx<
unsafe-fx>
unsafe-fx<=
unsafe-fx>=
unsafe-fxmin
unsafe-fxmax
unsafe-fl+
unsafe-fl-
unsafe-fl*
unsafe-fl/
unsafe-flabs
unsafe-fl=
unsafe-fl<
unsafe-fl>
unsafe-fl<=
unsafe-fl>=
unsafe-flmin
unsafe-flmax
unsafe-flround
unsafe-flfloor
unsafe-flceiling
unsafe-fltruncate
unsafe-flsingle
unsafe-flbit-field
unsafe-flsin
unsafe-flcos
unsafe-fltan
unsafe-flasin
unsafe-flacos
unsafe-flatan
unsafe-fllog
unsafe-flexp
unsafe-flsqrt
unsafe-flexpt
unsafe-make-flrectangular
unsafe-flreal-part
unsafe-flimag-part
unsafe-fx->fl
unsafe-fl->fx
unsafe-flrandom
17.2 Unsafe Character Operations
unsafe-char=?
unsafe-char<?
unsafe-char>?
unsafe-char<=?
unsafe-char>=?
unsafe-char->integer
17.3 Unsafe Compound-Data Operations
unsafe-car
unsafe-cdr
unsafe-mcar
unsafe-mcdr
unsafe-set-mcar!
unsafe-set-mcdr!
unsafe-cons-list
unsafe-list-ref
unsafe-list-tail
unsafe-set-immutable-car!
unsafe-set-immutable-cdr!
unsafe-unbox
unsafe-set-box!
unsafe-unbox*
unsafe-set-box*!
unsafe-box*-cas!
unsafe-vector-length
unsafe-vector-ref
unsafe-vector-set!
unsafe-vector-copy
unsafe-vector-set/  copy
unsafe-vector-append
unsafe-vector*-length
unsafe-vector*-ref
unsafe-vector*-set!
unsafe-vector*-cas!
unsafe-vector*-copy
unsafe-vector*-set/  copy
unsafe-vector*-append
unsafe-vector*->immutable-vector!
unsafe-string-length
unsafe-string-ref
unsafe-string-set!
unsafe-string->immutable-string!
unsafe-bytes-length
unsafe-bytes-ref
unsafe-bytes-set!
unsafe-bytes-copy!
unsafe-bytes->immutable-bytes!
unsafe-fxvector-length
unsafe-fxvector-ref
unsafe-fxvector-set!
unsafe-flvector-length
unsafe-flvector-ref
unsafe-flvector-set!
unsafe-f64vector-ref
unsafe-f64vector-set!
unsafe-s16vector-ref
unsafe-s16vector-set!
unsafe-u16vector-ref
unsafe-u16vector-set!
unsafe-stencil-vector
unsafe-stencil-vector-mask
unsafe-stencil-vector-length
unsafe-stencil-vector-ref
unsafe-stencil-vector-set!
unsafe-stencil-vector-update
unsafe-struct-ref
unsafe-struct-set!
unsafe-struct*-ref
unsafe-struct*-set!
unsafe-struct*-cas!
unsafe-struct*-type
unsafe-mutable-hash-iterate-first
unsafe-mutable-hash-iterate-next
unsafe-mutable-hash-iterate-key
unsafe-mutable-hash-iterate-value
unsafe-mutable-hash-iterate-key+  value
unsafe-mutable-hash-iterate-pair
unsafe-immutable-hash-iterate-first
unsafe-immutable-hash-iterate-next
unsafe-immutable-hash-iterate-key
unsafe-immutable-hash-iterate-value
unsafe-immutable-hash-iterate-key+  value
unsafe-immutable-hash-iterate-pair
unsafe-weak-hash-iterate-first
unsafe-weak-hash-iterate-next
unsafe-weak-hash-iterate-key
unsafe-weak-hash-iterate-value
unsafe-weak-hash-iterate-key+  value
unsafe-weak-hash-iterate-pair
unsafe-ephemeron-hash-iterate-first
unsafe-ephemeron-hash-iterate-next
unsafe-ephemeron-hash-iterate-key
unsafe-ephemeron-hash-iterate-value
unsafe-ephemeron-hash-iterate-key+  value
unsafe-ephemeron-hash-iterate-pair
unsafe-make-srcloc
17.4 Unsafe Extflonum Operations
unsafe-extfl+
unsafe-extfl-
unsafe-extfl*
unsafe-extfl/
unsafe-extflabs
unsafe-extfl=
unsafe-extfl<
unsafe-extfl>
unsafe-extfl<=
unsafe-extfl>=
unsafe-extflmin
unsafe-extflmax
unsafe-extflround
unsafe-extflfloor
unsafe-extflceiling
unsafe-extfltruncate
unsafe-extflsin
unsafe-extflcos
unsafe-extfltan
unsafe-extflasin
unsafe-extflacos
unsafe-extflatan
unsafe-extfllog
unsafe-extflexp
unsafe-extflsqrt
unsafe-extflexpt
unsafe-fx->extfl
unsafe-extfl->fx
unsafe-extflvector-length
unsafe-extflvector-ref
unsafe-extflvector-set!
17.5 Unsafe Impersonators and Chaperones
unsafe-impersonate-procedure
unsafe-chaperone-procedure
unsafe-impersonate-vector
unsafe-chaperone-vector
17.6 Unsafe Assertions
unsafe-assert-unreachable
17.7 Unsafe Structure Type Properties
unsafe-make-struct-type-property/  guard-calls-no-arguments
17.8 Unsafe Undefined
unsafe-undefined
check-not-unsafe-undefined
check-not-unsafe-undefined/  assign
chaperone-struct-unsafe-undefined
prop:  chaperone-unsafe-undefined

17 Unsafe Operations🔗

 (require racket/unsafe/ops) package: base

racket/baseracket 提供的所有函数和形式都会检查其参数,以确保参数符合合约和其他约束。例如,vector-ref 检查其参数以确保第一个参数是 vector,第二个参数是精确整数,且第二个参数在 0 到 vector 长度减一之间(含)。

racket/unsafe/ops 提供的函数是 不安全(unsafe)的。它们有特定的约束,但这些约束不会被检查,这使得系统能够生成和执行更快的代码。如果参数违反了不安全函数的约束,该函数的行为和结果是不可预测的,整个系统可能会崩溃或损坏。

racket/unsafe/ops 的所有导出绑定都受 protect-out 意义上的保护,因此可以通过调整代码检查器来阻止对不安全操作的访问(参见 Code Inspector)。

17.1 Unsafe Numeric Operations🔗

procedure

(unsafe-fx+ a ...)  fixnum?

  a : fixnum?

procedure

(unsafe-fx- a b ...)  fixnum?

  a : fixnum?
  b : fixnum?

procedure

(unsafe-fx* a ...)  fixnum?

  a : fixnum?

procedure

(unsafe-fxquotient a b)  fixnum?

  a : fixnum?
  b : fixnum?

procedure

(unsafe-fxremainder a b)  fixnum?

  a : fixnum?
  b : fixnum?

procedure

(unsafe-fxmodulo a b)  fixnum?

  a : fixnum?
  b : fixnum?

procedure

(unsafe-fxabs a)  fixnum?

  a : fixnum?
针对 fixnumsfx+fx-fx*fxquotientfxremainderfxmodulofxabs 的未检查版本。

Changed in version 7.0.0.13 of package base: 允许 unsafe-fx+unsafe-fx* 接受零个或多个参数,并允许 unsafe-fx- 接受一个或多个参数。

procedure

(unsafe-fxand a ...)  fixnum?

  a : fixnum?

procedure

(unsafe-fxior a ...)  fixnum?

  a : fixnum?

procedure

(unsafe-fxxor a ...)  fixnum?

  a : fixnum?

procedure

(unsafe-fxnot a)  fixnum?

  a : fixnum?

procedure

(unsafe-fxlshift a b)  fixnum?

  a : fixnum?
  b : fixnum?

procedure

(unsafe-fxrshift a b)  fixnum?

  a : fixnum?
  b : fixnum?

procedure

(unsafe-fxrshift/logical a b)  fixnum?

  a : fixnum?
  b : fixnum?
针对 fixnumsfxandfxiorfxxorfxnotfxlshiftfxrshiftfxrshift/logical 的未检查版本。

Changed in version 7.0.0.13 of package base: 允许 unsafe-fxandunsafe-fxiorunsafe-fxxor 接受零个或多个参数。
Changed in version 8.8.0.5: 添加了 unsafe-fxrshift/logical

procedure

(unsafe-fxpopcount a)  fixnum?

  a : (and/c fixnum? (not/c negative?))

procedure

(unsafe-fxpopcount32 a)  fixnum?

  a : (and/c fixnum? (integer-in 0 #xFFFFFFFF))

procedure

(unsafe-fxpopcount16 a)  fixnum?

  a : (and/c fixnum? (integer-in 0 #xFFFF))
针对 fixnumsfxpopcountfxpopcount32fxpopcount16 的未检查版本。

Added in version 8.5.0.6 of package base.

procedure

(unsafe-fx+/wraparound a b)  fixnum?

  a : fixnum?
  b : fixnum?

procedure

(unsafe-fx-/wraparound [a] b)  fixnum?

  a : fixnum? = 0
  b : fixnum?

procedure

(unsafe-fx*/wraparound a b)  fixnum?

  a : fixnum?
  b : fixnum?

procedure

(unsafe-fxlshift/wraparound a b)  fixnum?

  a : fixnum?
  b : fixnum?

Added in version 7.9.0.6 of package base.
Changed in version 8.15.0.12: 将 unsafe-fx-/wraparound 改为接受单个参数。

procedure

(unsafe-fx= a b ...)  boolean?

  a : fixnum?
  b : fixnum?

procedure

(unsafe-fx< a b ...)  boolean?

  a : fixnum?
  b : fixnum?

procedure

(unsafe-fx> a b ...)  boolean?

  a : fixnum?
  b : fixnum?

procedure

(unsafe-fx<= a b ...)  boolean?

  a : fixnum?
  b : fixnum?

procedure

(unsafe-fx>= a b ...)  boolean?

  a : fixnum?
  b : fixnum?

procedure

(unsafe-fxmin a b ...)  fixnum?

  a : fixnum?
  b : fixnum?

procedure

(unsafe-fxmax a b ...)  fixnum?

  a : fixnum?
  b : fixnum?
针对 fixnumsfx=fx<fx>fx<=fx>=fxminfxmax 的未检查版本。

Changed in version 7.0.0.13 of package base: 允许一个或多个参数,而非仅允许两个。

procedure

(unsafe-fl+ a ...)  flonum?

  a : flonum?

procedure

(unsafe-fl- a b ...)  flonum?

  a : flonum?
  b : flonum?

procedure

(unsafe-fl* a ...)  flonum?

  a : flonum?

procedure

(unsafe-fl/ a b ...)  flonum?

  a : flonum?
  b : flonum?

procedure

(unsafe-flabs a)  flonum?

  a : flonum?
针对 flonumsfl+fl-fl*fl/flabs 的未检查版本。

Changed in version 7.0.0.13 of package base: 允许 unsafe-fl+unsafe-fl* 接受零个或多个参数,并允许 unsafe-fl-unsafe-fl/ 接受一个或多个参数。

procedure

(unsafe-fl= a b ...)  boolean?

  a : flonum?
  b : flonum?

procedure

(unsafe-fl< a b ...)  boolean?

  a : flonum?
  b : flonum?

procedure

(unsafe-fl> a b ...)  boolean?

  a : flonum?
  b : flonum?

procedure

(unsafe-fl<= a b ...)  boolean?

  a : flonum?
  b : flonum?

procedure

(unsafe-fl>= a b ...)  boolean?

  a : flonum?
  b : flonum?

procedure

(unsafe-flmin a b ...)  flonum?

  a : flonum?
  b : flonum?

procedure

(unsafe-flmax a b ...)  flonum?

  a : flonum?
  b : flonum?
针对 flonumsfl=fl<fl>fl<=fl>=flminflmax 的未检查版本。

Changed in version 7.0.0.13 of package base: 允许一个或多个参数,而非仅允许两个。

procedure

(unsafe-flround a)  flonum?

  a : flonum?

procedure

(unsafe-flfloor a)  flonum?

  a : flonum?

procedure

(unsafe-flceiling a)  flonum?

  a : flonum?

procedure

(unsafe-fltruncate a)  flonum?

  a : flonum?
针对 flonumsflroundflfloorflceilingfltruncate 的(潜在)未检查版本。目前,这些绑定只是相应安全绑定的别名。

procedure

(unsafe-flsingle a)  flonum?

  a : flonum?
针对 flonumsflsingle 的(潜在)未检查版本。

Added in version 7.8.0.7 of package base.

procedure

(unsafe-flbit-field a start end)  exact-nonnegative-integer?

  a : flonum?
  start : (integer-in 0 64)
  end : (integer-in 0 64)
针对 flonumsflbit-field 的未检查版本。

Added in version 8.15.0.3 of package base.

procedure

(unsafe-flsin a)  flonum?

  a : flonum?

procedure

(unsafe-flcos a)  flonum?

  a : flonum?

procedure

(unsafe-fltan a)  flonum?

  a : flonum?

procedure

(unsafe-flasin a)  flonum?

  a : flonum?

procedure

(unsafe-flacos a)  flonum?

  a : flonum?

procedure

(unsafe-flatan a)  flonum?

  a : flonum?

procedure

(unsafe-fllog a)  flonum?

  a : flonum?

procedure

(unsafe-flexp a)  flonum?

  a : flonum?

procedure

(unsafe-flsqrt a)  flonum?

  a : flonum?

procedure

(unsafe-flexpt a b)  flonum?

  a : flonum?
  b : flonum?
针对 flonumsflsinflcosfltanflasinflacosflatanfllogflexpflsqrtflexpt 的(潜在)未检查版本。目前,其中一些绑定只是相应安全绑定的别名。

procedure

(unsafe-make-flrectangular a b)

  
(and/c complex?
       (lambda (c) (flonum? (real-part c)))
       (lambda (c) (flonum? (imag-part c))))
  a : flonum?
  b : flonum?

procedure

(unsafe-flreal-part a)  flonum?

  a : 
(and/c complex?
       (lambda (c) (flonum? (real-part c)))
       (lambda (c) (flonum? (imag-part c))))

procedure

(unsafe-flimag-part a)  flonum?

  a : 
(and/c complex?
       (lambda (c) (flonum? (real-part c)))
       (lambda (c) (flonum? (imag-part c))))
针对 flonumsmake-flrectangularflreal-partflimag-part 的未检查版本。

procedure

(unsafe-fx->fl a)  flonum?

  a : fixnum?

procedure

(unsafe-fl->fx a)  fixnum?

  a : flonum?
fx->flfl->fx 的未检查版本。

Changed in version 7.7.0.8 of package base: 将 unsafe-fl->fx 改为截断。

procedure

(unsafe-flrandom rand-gen)  (and flonum? (>/c 0) (</c 1))

  rand-gen : pseudo-random-generator?
flrandom 的未检查版本。

17.2 Unsafe Character Operations🔗

procedure

(unsafe-char=? a b ...)  boolean?

  a : char?
  b : char?

procedure

(unsafe-char<? a b ...)  boolean?

  a : char?
  b : char?

procedure

(unsafe-char>? a b ...)  boolean?

  a : char?
  b : char?

procedure

(unsafe-char<=? a b ...)  boolean?

  a : char?
  b : char?

procedure

(unsafe-char>=? a b ...)  boolean?

  a : char?
  b : char?

procedure

(unsafe-char->integer a)  fixnum?

  a : char?
char=?char<?char>?char<=?char>=?char->integer 的未检查版本。

Added in version 7.0.0.14 of package base.

17.3 Unsafe Compound-Data Operations🔗

procedure

(unsafe-car p)  any/c

  p : pair?

procedure

(unsafe-cdr p)  any/c

  p : pair?

procedure

(unsafe-mcar p)  any/c

  p : mpair?

procedure

(unsafe-mcdr p)  any/c

  p : mpair?

procedure

(unsafe-set-mcar! p v)  void?

  p : mpair?
  v : any/c

procedure

(unsafe-set-mcdr! p v)  void?

  p : mpair?
  v : any/c
carcdrmcarmcdrset-mcar!set-mcdr! 的不安全变体。

procedure

(unsafe-cons-list v rest)  (and/c pair? list?)

  v : any/c
  rest : list?
cons 的不安全变体,生成一个声称是列表的 pair—而不检查 rest 是否是列表。

procedure

(unsafe-list-ref lst pos)  any/c

  lst : pair?
  pos : (and/c exact-nonnegative-integer? fixnum?)

procedure

(unsafe-list-tail lst pos)  any/c

  lst : any/c
  pos : (and/c exact-nonnegative-integer? fixnum?)
list-reflist-tail 的不安全变体,其中 pos 必须是 fixnum,且 lst 必须至少以 (add1 pos)(对于 unsafe-list-ref)或 pos(对于 unsafe-list-tail)个 pair 开头。

procedure

(unsafe-set-immutable-car! p v)  void?

  p : pair?
  v : any/c

procedure

(unsafe-set-immutable-cdr! p v)  void?

  p : pair?
  v : any/c
正如它们矛盾修辞的名称所示,使用这些函数 没有普遍正确的方式。尽管如此,它们可能作为最后的手段有用,在 pair 以受限方式使用且对 Racket 的实现做出正确假设(包括对编译器优化限制的假设)的情况下。

使用 unsafe-set-immutable-car!unsafe-set-immutable-cdr! 的一些陷阱:

  • 消费 pair 的函数可能会利用不可变性,例如计算列表的长度一次并期望列表保持该长度,或根据合约检查列表并期望合约此后保持。

  • 对 pair 调用 list? 的结果可能在内部缓存,因此将 pair 的 cdr 从列表改为非列表或反之可能会导致 list? 产生错误的值—对于被修改的 pair 或到达被修改 pair 的其他 pair。

  • 编译器可能基于 pair 是不可变的理由,重新排序甚至优化掉对 carcdr 的调用,在这种情况下,unsafe-set-immutable-car!unsafe-set-immutable-cdr! 可能不会对 carcdr 的使用产生影响。

Added in version 7.9.0.18 of package base.

procedure

(unsafe-unbox b)  any/c

  b : box?

procedure

(unsafe-set-box! b k)  void?

  b : box?
  k : any/c

procedure

(unsafe-unbox* v)  any/c

  v : (and/c box? (not/c impersonator?))

procedure

(unsafe-set-box*! v val)  void?

  v : (and/c box? (not/c impersonator?))
  val : any/c
unboxset-box! 的不安全版本,其中 box* 变体可以更快,但不能用于 拟人化对象(impersonator)。

procedure

(unsafe-box*-cas! loc old new)  boolean?

  loc : box?
  old : any/c
  new : any/c
box-cas! 的不安全版本。与 unsafe-set-box*! 一样,它不能用于 拟人化对象

procedure

(unsafe-vector-length v)  fixnum?

  v : vector?

procedure

(unsafe-vector-ref v k)  any/c

  v : vector?
  k : fixnum?

procedure

(unsafe-vector-set! v k val)  void?

  v : vector?
  k : fixnum?
  val : any/c

procedure

(unsafe-vector-copy v [start end])  vector?

  v : vector?
  start : fixnum? = 0
  end : fixnum? = (vector-length v)

procedure

(unsafe-vector-set/copy v [pos] val)  vector?

  v : vector?
  pos : fixnum? = 0
  val : any/c

procedure

(unsafe-vector-append v ...)  vector?

  v : vector?

procedure

(unsafe-vector*-length v)  fixnum?

  v : (and/c vector? (not/c impersonator?))

procedure

(unsafe-vector*-ref v k)  any/c

  v : (and/c vector? (not/c impersonator?))
  k : fixnum?

procedure

(unsafe-vector*-set! v k val)  void?

  v : (and/c vector? (not/c impersonator?))
  k : fixnum?
  val : any/c

procedure

(unsafe-vector*-cas! v k old-val new-val)  boolean?

  v : (and/c vector? (not/c impersonator?))
  k : fixnum?
  old-val : any/c
  new-val : any/c

procedure

(unsafe-vector*-copy v [start end])  vector?

  v : vector?
  start : fixnum? = 0
  end : fixnum? = (vector-length v)

procedure

(unsafe-vector*-set/copy v pos val)  vector?

  v : vector?
  pos : fixnum?
  val : any/c

procedure

(unsafe-vector*-append v ...)  vector?

  v : vector?
vector-lengthvector-refvector-set!vector-cas!vector-copyvector-set/copyvector-append 的不安全版本,其中 vector* 变体可以更快,但不能用于 拟人化对象

vector 的大小永远不能大于 fixnum,因此即使是 vector-length 也总是返回 fixnum。

Changed in version 6.11.0.2 of package base: 添加了 unsafe-vector*-cas!
Changed in version 8.11.1.9: 添加了 unsafe-vector-copyunsafe-vector*-copyunsafe-vector-set/copyunsafe-vector*-set/copyunsafe-vector-appendunsafe-vector*-append

类似 vector->immutable-vector,但可能会销毁 v 并重用其空间,因此在调用 unsafe-vector*->immutable-vector! 后不得使用 v

Added in version 7.7.0.6 of package base.

procedure

(unsafe-string-length str)  fixnum?

  str : string?

procedure

(unsafe-string-ref str k)

  (and/c char? (lambda (ch) (<= 0 (char->integer ch) 255)))
  str : string?
  k : fixnum?

procedure

(unsafe-string-set! str k ch)  void?

  str : (and/c string? (not/c immutable?))
  k : fixnum?
  ch : char?
string-lengthstring-refstring-set! 的不安全版本。unsafe-string-ref 过程只能在结果为 Latin-1 字符时使用。字符串的大小永远不能大于 fixnum(因此即使是 string-length 也总是返回 fixnum)。

procedure

(unsafe-string->immutable-string! str)

  (and/c string? immutable?)
  str : string?
类似 string->immutable-string,但可能会销毁 str 并重用其空间,因此在调用 unsafe-string->immutable-string! 后不得使用 str

Added in version 7.7.0.6 of package base.

procedure

(unsafe-bytes-length bstr)  fixnum?

  bstr : bytes?

procedure

(unsafe-bytes-ref bstr k)  byte?

  bstr : bytes?
  k : fixnum?

procedure

(unsafe-bytes-set! bstr k b)  void?

  bstr : (and/c bytes? (not/c immutable?))
  k : fixnum?
  b : byte?

procedure

(unsafe-bytes-copy! dest    
  dest-start    
  src    
  [src-start    
  src-end])  void?
  dest : (and/c bytes? (not/c immutable?))
  dest-start : fixnum?
  src : bytes?
  src-start : fixnum? = 0
  src-end : fixnum? = (bytes-length src)
bytes-lengthbytes-refbytes-set!bytes-copy! 的不安全版本。bytes 的大小永远不能大于 fixnum(因此即使是 bytes-length 也总是返回 fixnum)。

Changed in version 7.5.0.15 of package base: 添加了 unsafe-bytes-copy!

procedure

(unsafe-bytes->immutable-bytes! bstr)

  (and/c bytes? immutable?)
  bstr : bytes?
类似 bytes->immutable-bytes,但可能会销毁 bstr 并重用其空间,因此在调用 unsafe-bytes->immutable-bytes! 后不得使用 bstr

Added in version 7.7.0.6 of package base.

procedure

(unsafe-fxvector-length v)  fixnum?

  v : fxvector?

procedure

(unsafe-fxvector-ref v k)  fixnum?

  v : fxvector?
  k : fixnum?

procedure

(unsafe-fxvector-set! v k x)  void?

  v : fxvector?
  k : fixnum?
  x : fixnum?
fxvector-lengthfxvector-reffxvector-set! 的不安全版本。fxvector 的大小永远不能大于 fixnum(因此即使是 fxvector-length 也总是返回 fixnum)。

procedure

(unsafe-flvector-length v)  fixnum?

  v : flvector?

procedure

(unsafe-flvector-ref v k)  flonum?

  v : flvector?
  k : fixnum?

procedure

(unsafe-flvector-set! v k x)  void?

  v : flvector?
  k : fixnum?
  x : flonum?
flvector-lengthflvector-refflvector-set! 的不安全版本。flvector 的大小永远不能大于 fixnum(因此即使是 flvector-length 也总是返回 fixnum)。

procedure

(unsafe-f64vector-ref vec k)  flonum?

  vec : f64vector?
  k : fixnum?

procedure

(unsafe-f64vector-set! vec k n)  void?

  vec : f64vector?
  k : fixnum?
  n : flonum?
f64vector-reff64vector-set! 的不安全版本。

procedure

(unsafe-s16vector-ref vec k)  (integer-in -32768 32767)

  vec : s16vector?
  k : fixnum?

procedure

(unsafe-s16vector-set! vec k n)  void?

  vec : s16vector?
  k : fixnum?
  n : (integer-in -32768 32767)
s16vector-refs16vector-set! 的不安全版本。

procedure

(unsafe-u16vector-ref vec k)  (integer-in 0 65535)

  vec : u16vector?
  k : fixnum?

procedure

(unsafe-u16vector-set! vec k n)  void?

  vec : u16vector?
  k : fixnum?
  n : (integer-in 0 65535)
u16vector-refu16vector-set! 的不安全版本。

procedure

(unsafe-stencil-vector mask v ...)  stencil-vector?

  mask : (integer-in 0 (sub1 (expt 2 (stencil-vector-mask-width))))
  v : any/c

procedure

(unsafe-stencil-vector-mask vec)

  (integer-in 0 (sub1 (expt 2 (stencil-vector-mask-width))))
  vec : stencil-vector?

procedure

(unsafe-stencil-vector-length vec)

  (integer-in 0 (sub1 (stencil-vector-mask-width)))
  vec : stencil-vector?

procedure

(unsafe-stencil-vector-ref vec pos)  any/c

  vec : stencil-vector?
  pos : exact-nonnegative-integer?

procedure

(unsafe-stencil-vector-set! vec pos v)  void?

  vec : stencil-vector?
  pos : exact-nonnegative-integer?
  v : any/c

procedure

(unsafe-stencil-vector-update vec    
  remove-mask    
  add-mask    
  v ...)  stencil-vector?
  vec : stencil-vector?
  remove-mask : (integer-in 0 (sub1 (expt 2 (stencil-vector-mask-width))))
  add-mask : (integer-in 0 (sub1 (expt 2 (stencil-vector-mask-width))))
  v : any/c

Added in version 8.5.0.7 of package base.

procedure

(unsafe-struct-ref v k)  any/c

  v : any/c
  k : fixnum?

procedure

(unsafe-struct-set! v k val)  void?

  v : any/c
  k : fixnum?
  val : any/c

procedure

(unsafe-struct*-ref v k)  any/c

  v : (not/c impersonator?)
  k : fixnum?

procedure

(unsafe-struct*-set! v k val)  void?

  v : (not/c impersonator?)
  k : fixnum?
  val : any/c

procedure

(unsafe-struct*-cas! v k old-val new-val)  boolean?

  v : (not/c impersonator?)
  k : fixnum?
  old-val : any/c
  new-val : any/c
用于结构类型实例的不安全字段访问和更新,其中 struct* 变体可以更快,但不能用于 拟人化对象。索引 k 必须在 0(含)到结构中字段的数量(不含)之间。对于 unsafe-struct-set!unsafe-struct*-set!unsafe-struct*-cas!,字段必须是可变的。unsafe-struct*-cas! 操作类似于 box-cas!,执行原子比较并设置。

Changed in version 6.11.0.2 of package base: 添加了 unsafe-struct*-cas!

procedure

(unsafe-struct*-type v)  struct-type?

  v : any/c
类似 struct-info,但不进行检查器检查,仅返回第一个结果,且不支持 拟人化对象

Added in version 8.8.0.3 of package base.

procedure

(unsafe-mutable-hash-iterate-first hash)  (or/c #f any/c)

  hash : (and/c hash? (not/c immutable?) hash-strong?)

procedure

(unsafe-mutable-hash-iterate-next hash pos)  (or/c #f any/c)

  hash : (and/c hash? (not/c immutable?) hash-strong?)
  pos : any/c

procedure

(unsafe-mutable-hash-iterate-key hash pos)  any/c

  hash : (and/c hash? (not/c immutable?) hash-strong?)
  pos : any/c

procedure

(unsafe-mutable-hash-iterate-key hash    
  pos    
  bad-index-v)  any/c
  hash : (and/c hash? (not/c immutable?) hash-strong?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-mutable-hash-iterate-value hash    
  pos)  any/c
  hash : (and/c hash? (not/c immutable?) hash-strong?)
  pos : any/c

procedure

(unsafe-mutable-hash-iterate-value hash    
  pos    
  bad-index-v)  any/c
  hash : (and/c hash? (not/c immutable?) hash-strong?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-mutable-hash-iterate-key+value hash    
  pos)  
any/c any/c
  hash : (and/c hash? (not/c immutable?) hash-strong?)
  pos : any/c

procedure

(unsafe-mutable-hash-iterate-key+value hash 
  pos 
  bad-index-v) 
  
any/c any/c
  hash : (and/c hash? (not/c immutable?) hash-strong?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-mutable-hash-iterate-pair hash pos)  pair?

  hash : (and/c hash? (not/c immutable?) hash-strong?)
  pos : any/c

procedure

(unsafe-mutable-hash-iterate-pair hash    
  pos    
  bad-index-v)  pair?
  hash : (and/c hash? (not/c immutable?) hash-strong?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-immutable-hash-iterate-first hash)  (or/c #f any/c)

  hash : (and/c hash? immutable?)

procedure

(unsafe-immutable-hash-iterate-next hash    
  pos)  (or/c #f any/c)
  hash : (and/c hash? immutable?)
  pos : any/c

procedure

(unsafe-immutable-hash-iterate-key hash    
  pos)  any/c
  hash : (and/c hash? immutable?)
  pos : any/c

procedure

(unsafe-immutable-hash-iterate-key hash    
  pos    
  bad-index-v)  any/c
  hash : (and/c hash? immutable?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-immutable-hash-iterate-value hash    
  pos)  any/c
  hash : (and/c hash? immutable?)
  pos : any/c

procedure

(unsafe-immutable-hash-iterate-value hash    
  pos    
  bad-index-v)  any/c
  hash : (and/c hash? immutable?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-immutable-hash-iterate-key+value hash    
  pos)  
any/c any/c
  hash : (and/c hash? immutable?)
  pos : any/c

procedure

(unsafe-immutable-hash-iterate-key+value hash 
  pos 
  bad-index-v) 
  
any/c any/c
  hash : (and/c hash? immutable?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-immutable-hash-iterate-pair hash    
  pos)  pair?
  hash : (and/c hash? immutable?)
  pos : any/c

procedure

(unsafe-immutable-hash-iterate-pair hash    
  pos    
  bad-index-v)  pair?
  hash : (and/c hash? immutable?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-weak-hash-iterate-first hash)  (or/c #f any/c)

  hash : (and/c hash? hash-weak?)

procedure

(unsafe-weak-hash-iterate-next hash pos)  (or/c #f any/c)

  hash : (and/c hash? hash-weak?)
  pos : any/c

procedure

(unsafe-weak-hash-iterate-key hash pos)  any/c

  hash : (and/c hash? hash-weak?)
  pos : any/c

procedure

(unsafe-weak-hash-iterate-key hash    
  pos    
  bad-index-v)  any/c
  hash : (and/c hash? hash-weak?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-weak-hash-iterate-value hash pos)  any/c

  hash : (and/c hash? hash-weak?)
  pos : any/c

procedure

(unsafe-weak-hash-iterate-value hash    
  pos    
  bad-index-v)  any/c
  hash : (and/c hash? hash-weak?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-weak-hash-iterate-key+value hash    
  pos)  
any/c any/c
  hash : (and/c hash? hash-weak?)
  pos : any/c

procedure

(unsafe-weak-hash-iterate-key+value hash    
  pos    
  bad-index-v)  
any/c any/c
  hash : (and/c hash? hash-weak?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-weak-hash-iterate-pair hash pos)  pair?

  hash : (and/c hash? hash-weak?)
  pos : any/c

procedure

(unsafe-weak-hash-iterate-pair hash    
  pos    
  bad-index-v)  pair?
  hash : (and/c hash? hash-weak?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-ephemeron-hash-iterate-first hash)  (or/c #f any/c)

  hash : (and/c hash? hash-ephemeron?)

procedure

(unsafe-ephemeron-hash-iterate-next hash    
  pos)  (or/c #f any/c)
  hash : (and/c hash? hash-ephemeron?)
  pos : any/c

procedure

(unsafe-ephemeron-hash-iterate-key hash    
  pos)  any/c
  hash : (and/c hash? hash-ephemeron?)
  pos : any/c

procedure

(unsafe-ephemeron-hash-iterate-key hash    
  pos    
  bad-index-v)  any/c
  hash : (and/c hash? hash-ephemeron?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-ephemeron-hash-iterate-value hash    
  pos)  any/c
  hash : (and/c hash? hash-ephemeron?)
  pos : any/c

procedure

(unsafe-ephemeron-hash-iterate-value hash    
  pos    
  bad-index-v)  any/c
  hash : (and/c hash? hash-ephemeron?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-ephemeron-hash-iterate-key+value hash    
  pos)  
any/c any/c
  hash : (and/c hash? hash-ephemeron?)
  pos : any/c

procedure

(unsafe-ephemeron-hash-iterate-key+value hash 
  pos 
  bad-index-v) 
  
any/c any/c
  hash : (and/c hash? hash-ephemeron?)
  pos : any/c
  bad-index-v : any/c

procedure

(unsafe-ephemeron-hash-iterate-pair hash    
  pos)  pair?
  hash : (and/c hash? hash-ephemeron?)
  pos : any/c

procedure

(unsafe-ephemeron-hash-iterate-pair hash    
  pos    
  bad-index-v)  pair?
  hash : (and/c hash? hash-ephemeron?)
  pos : any/c
  bad-index-v : any/c
hash-iterate-key 及类似过程的不安全版本。这些操作支持 监护(chaperone)和 拟人化对象(impersonator)。

每个不安全的 ...-first 和 ...-next 过程可能返回哈希结构视图的内部表示而非数字索引,从而实现更快的迭代。这些 ...-first 和 ...-next 函数的结果应作为 pos 传递给相应的不安全访问器函数。

如果提供给可变 hash 访问器函数的 pos 之前是 有效哈希索引,但不再是 hash有效哈希索引,且未提供 bad-index-v,则 exn:fail:contract exception is raised。对于从未是 hash有效哈希索引pos,未指定行为。注意,bad-index-v 参数在技术上对 unsafe-immutable-hash-iterate- 函数无用,因为对于不可变 hash,索引不会变为无效。

Added in version 6.4.0.6 of package base.
Changed in version 7.0.0.10: 添加了可选的 bad-index-v 参数。
Changed in version 8.0.0.10: 添加了 ephemeron 变体。

procedure

(unsafe-make-srcloc source    
  line    
  column    
  position    
  span)  srcloc?
  source : any/c
  line : (or/c exact-positive-integer? #f)
  column : (or/c exact-nonnegative-integer? #f)
  position : (or/c exact-positive-integer? #f)
  span : (or/c exact-nonnegative-integer? #f)
srcloc 的不安全版本。

Added in version 7.2.0.10 of package base.

17.4 Unsafe Extflonum Operations🔗

procedure

(unsafe-extfl+ a b)  extflonum?

  a : extflonum?
  b : extflonum?

procedure

(unsafe-extfl- a b)  extflonum?

  a : extflonum?
  b : extflonum?

procedure

(unsafe-extfl* a b)  extflonum?

  a : extflonum?
  b : extflonum?

procedure

(unsafe-extfl/ a b)  extflonum?

  a : extflonum?
  b : extflonum?

procedure

(unsafe-extflabs a)  extflonum?

  a : extflonum?
extfl+extfl-extfl*extfl/extflabs 的未检查版本。

procedure

(unsafe-extfl= a b)  boolean?

  a : extflonum?
  b : extflonum?

procedure

(unsafe-extfl< a b)  boolean?

  a : extflonum?
  b : extflonum?

procedure

(unsafe-extfl> a b)  boolean?

  a : extflonum?
  b : extflonum?

procedure

(unsafe-extfl<= a b)  boolean?

  a : extflonum?
  b : extflonum?

procedure

(unsafe-extfl>= a b)  boolean?

  a : extflonum?
  b : extflonum?

procedure

(unsafe-extflmin a b)  extflonum?

  a : extflonum?
  b : extflonum?

procedure

(unsafe-extflmax a b)  extflonum?

  a : extflonum?
  b : extflonum?
extfl=extfl<extfl>extfl<=extfl>=extflminextflmax 的未检查版本。

procedure

(unsafe-extflround a)  extflonum?

  a : extflonum?

procedure

(unsafe-extflfloor a)  extflonum?

  a : extflonum?

procedure

(unsafe-extflceiling a)  extflonum?

  a : extflonum?

procedure

(unsafe-extfltruncate a)  extflonum?

  a : extflonum?
extflroundextflfloorextflceilingextfltruncate 的(潜在)未检查版本。目前,这些绑定只是相应安全绑定的别名。

procedure

(unsafe-extflsin a)  extflonum?

  a : extflonum?

procedure

(unsafe-extflcos a)  extflonum?

  a : extflonum?

procedure

(unsafe-extfltan a)  extflonum?

  a : extflonum?

procedure

(unsafe-extflasin a)  extflonum?

  a : extflonum?

procedure

(unsafe-extflacos a)  extflonum?

  a : extflonum?

procedure

(unsafe-extflatan a)  extflonum?

  a : extflonum?

procedure

(unsafe-extfllog a)  extflonum?

  a : extflonum?

procedure

(unsafe-extflexp a)  extflonum?

  a : extflonum?

procedure

(unsafe-extflsqrt a)  extflonum?

  a : extflonum?

procedure

(unsafe-extflexpt a b)  extflonum?

  a : extflonum?
  b : extflonum?
extflsinextflcosextfltanextflasinextflacosextflatanextfllogextflexpextflsqrtextflexpt 的(潜在)未检查版本。目前,其中一些绑定只是相应安全绑定的别名。

procedure

(unsafe-fx->extfl a)  extflonum?

  a : fixnum?

procedure

(unsafe-extfl->fx a)  fixnum?

  a : extflonum?
fx->extflextfl->fx 的(潜在)未检查版本。

Changed in version 7.7.0.8 of package base: 将 unsafe-fl->fx 改为截断。

procedure

(unsafe-extflvector-length v)  fixnum?

  v : extflvector?

procedure

(unsafe-extflvector-ref v k)  extflonum?

  v : extflvector?
  k : fixnum?

procedure

(unsafe-extflvector-set! v k x)  void?

  v : extflvector?
  k : fixnum?
  x : extflonum?
extflvector-lengthextflvector-refextflvector-set! 的未检查版本。extflvector 的大小永远不能大于 fixnum(因此即使是 extflvector-length 也总是返回 fixnum)。

17.5 Unsafe Impersonators and Chaperones🔗

procedure

(unsafe-impersonate-procedure proc 
  replacement-proc 
  prop 
  prop-val ... 
  ...) 
  (and/c procedure? impersonator?)
  proc : procedure?
  replacement-proc : procedure?
  prop : impersonator-property?
  prop-val : any
类似 impersonate-procedure,但假定 replacement-proc 自身调用 proc。当 unsafe-impersonate-procedure 的结果应用于参数时,参数直接传递给 replacement-proc,忽略 proc。同时,impersonator-of? 在给定 unsafe-impersonate-procedure 的结果和 proc 时报告 #t

如果 proc 本身是从 impersonate-procedure*chaperone-procedure* 派生的拟人化对象,注意 replacement-proc 将无法正确调用它。具体来说,由 unsafe-impersonate-procedure 生成的拟人化对象不会传递给提供给 impersonate-procedure*chaperone-procedure* 以生成 proc 的包装过程。

最后,与 impersonate-procedure 不同,unsafe-impersonate-procedure 不会将 impersonator-prop:application-mark 作为 prop 特殊处理。

unsafe-impersonate-procedure 的不安全性仅限于上述与 impersonate-procedure 的区别。unsafe-impersonate-procedure 的参数合约在提供参数时进行检查。

作为一个示例,假设 f 接受单个参数且非从 impersonate-procedure*chaperone-procedure* 派生,则
(λ (f)
  (unsafe-impersonate-procedure
   f
   (λ (x)
     (if (number? x)
         (error 'no-numbers!)
         (f x)))))
等价于
(λ (f)
  (impersonate-procedure
   f
   (λ (x)
     (if (number? x)
         (error 'no-numbers!)
         x))))

类似地,在同样关于 f 的假设下,以下两个过程 wrap-f1wrap-f2 几乎等价;它们仅在参数是返回多值的函数时产生的错误消息不同(且它们更新不同的全局变量)。使用 unsafe-impersonate-procedure 的版本将在 let 表达式中发出关于多个返回值的错误,而使用 impersonate-procedure 的版本从 impersonate-procedure 发出关于多个返回值的错误。
(define log1-args '())
(define log1-results '())
(define wrap-f1
  (λ (f)
    (impersonate-procedure
     f
     (λ (arg)
       (set! log1-args (cons arg log1-args))
       (values (λ (res)
                 (set! log1-results (cons res log1-results))
                 res)
               arg)))))
 
(define log2-args '())
(define log2-results '())
(define wrap-f2
  (λ (f)
    (unsafe-impersonate-procedure
     f
     (λ (arg)
       (set! log2-args (cons arg log2-args))
       (let ([res (f arg)])
         (set! log2-results (cons res log2-results))
         res)))))

Added in version 6.4.0.4 of package base.

procedure

(unsafe-chaperone-procedure proc 
  wrapper-proc 
  prop 
  prop-val ... 
  ...) 
  (and/c procedure? chaperone?)
  proc : procedure?
  wrapper-proc : procedure?
  prop : impersonator-property?
  prop-val : any
类似 unsafe-impersonate-procedure,但创建 监护(chaperone)。由于 wrapper-proc 将代替 proc 被调用,假定 wrapper-proc 返回 proc 将返回的值的监护。

Added in version 6.4.0.4 of package base.

procedure

(unsafe-impersonate-vector vec 
  replacement-vec 
  prop 
  prop-val ... 
  ...) 
  (and/c vector? impersonator?)
  vec : vector?
  replacement-vec : (and/c vector? (not/c impersonator?))
  prop : impersonator-property?
  prop-val : any/c
类似 impersonate-vector,但不通过插入过程,所有对拟人化对象的访问都分发到 replacement-vec

unsafe-impersonate-vector 的结果是 vec 的拟人化对象。

Added in version 6.9.0.2 of package base.

procedure

(unsafe-chaperone-vector vec 
  replacement-vec 
  prop 
  prop-val ... 
  ...) 
  (and/c vector? chaperone?)
  vec : vector?
  replacement-vec : (and/c vector? (not/c impersonator?))
  prop : impersonator-property?
  prop-val : any/c
类似 unsafe-impersonate-vector,但 unsafe-chaperone-vector 的结果是 vec 的监护。

Added in version 6.9.0.2 of package base.

17.6 Unsafe Assertions🔗

类似 assert-unreachable,但 unsafe-assert-unreachable 的合约永远不会被满足,"不安全"的含义是,如果到达对 unsafe-assert-unreachable 的调用,任何事情都可能发生。

编译器可以利用其自由,选择便捷或高效的行为来代替对 unsafe-assert-unreachable 的调用。例如,表达式

(lambda (x)
  (if (pair? x)
      (car x)
      (unsafe-assert-unreachable)))

可能被编译为等价于以下代码

(lambda (x) (unsafe-car x))

因为选择让 (unsafe-assert-unreachable) 的行为与 (unsafe-car x) 相同,使得 if 的两个分支相同,从而可以消除 pair? 测试。

Added in version 8.0.0.11 of package base.

17.7 Unsafe Structure Type Properties🔗

The bindings documented in this section are provided by the racket/unsafe/struct-type-property library, not racket/base or racket.

procedure

(unsafe-make-struct-type-property/guard-calls-no-arguments 
  name 
  [guard 
  supers 
  can-impersonate? 
  accessor-name 
  contract-str 
  realm]) 
  
struct-type-property?
(any/c . -> . boolean?)
procedure?
  name : symbol?
  guard : (or/c procedure? #f 'can-impersonate) = #f
  supers : 
(listof (cons/c struct-type-property?
                (any/c . -> . any/c)))
 = null
  can-impersonate? : any/c = #f
  accessor-name : (or/c symbol? #f) = #f
  contract-str : (or/c string? symbol? #f) = #f
  realm : symbol? = 'racket
make-struct-type-property 相同,但断言 guard 不调用包含在其属性值参数中的任何过程。类似地,supers 中没有过程调用被包含的过程,且 supers 中的属性没有调用被包含过程的 guard 或转换。

断言给定过程不会被属性的 guard 调用,可以减少检查并改进对使用该属性的结构类型操作的优化。具体来说,当由 unsafe-make-struct-type-property/guard-calls-no-arguments 创建的属性用于结构类型声明时,并且当为该属性提供的值包含引用回结构类型声明绑定的过程(这是方法类属性的常见模式)时,编译器可以更容易地得出结论:在属性值中引用的已定义名称不会被过早引用。

Added in version 8.18.0.18 of package base.

17.8 Unsafe Undefined🔗

The bindings documented in this section are provided by the racket/unsafe/undefined library, not racket/base or racket.

常量 unsafe-undefined 在内部被用作占位值。例如,它被 letrec 用作尚未赋值的 variable 的值。然而,与 racket/undefined 导出的 undefined 值不同,unsafe-undefined 值不应泄露为某个安全表达式的结果,也不应作为可选参数传给 procedure(因为可能被视作"未提供值")。 可能产生 unsafe-undefined 的表达式结果可以由 check-not-unsafe-undefined 保护,以便在产生 undefined 值之前引发异常。

unsafe-undefined 值始终与自身是 eq? 的。

Added in version 6.0.1.2 of package base.
Changed in version 6.90.0.29: 带有可选参数的 Procedure 有时会在内部使用 unsafe-undefined 来表示"未提供参数"。

不安全的"undefined"常量。

参见上面了解 unsafe-undefined 使用的重要约束条件。

procedure

(check-not-unsafe-undefined v sym)  any/c

  v : any/c
  sym : symbol?
检查 v 是否为 unsafe-undefined,如果是则引发 exn:fail:contract:variable 异常,其错误消息形如“sym:undefined;在初始化前使用”。如果 v 不是 unsafe-undefined,则返回 v

procedure

(check-not-unsafe-undefined/assign v sym)  any/c

  v : any/c
  sym : symbol?
check-not-unsafe-undefined 相同,不过其错误消息(如果有)形如"sym:undefined;在初始化前赋值"。

procedure

(chaperone-struct-unsafe-undefined v)  any/c

  v : any/c
如果 v 是一个通过某 inspector 看到的结构,则 chaperone 它。对结构中每个字段的访问都会进行检查,防止返回 unsafe-undefined。同样,对结构中每个字段的赋值也会进行检查(除非检查已被如下方式禁用),防止将字段的当前值为 unsafe-undefined 的字段赋值。

当某个字段访问可能产生 unsafe-undefined 或某个字段赋值可能替换 unsafe-undefined 时,会引发 exn:fail:contract 异常。

(continuation-mark-set-first #f prop:chaperone-unsafe-undefined) 返回 unsafe-undefined 时,chaperone 的字段赋值检查被禁用。因此,字段初始化赋值——旨在替换字段 unsafe-undefined 值的赋值——应包裹在 (with-continuation-mark prop:chaperone-unsafe-undefined unsafe-undefined ....) 中。

一个 结构类型属性,使结构类型的构造函数以与 chaperone-struct-unsafe-undefined 相同的方式 chaperone 实例。

属性值应为一个用作字段名称的 symbol 列表,但顺序应与结构字段顺序相反。当某个字段访问或赋值会产生或替换 unsafe-undefined 时,如果字段名称由结构属性的值提供,则引发 exn:fail:contract:variable 异常,否则引发 exn:fail:contract 异常。