3 Values and Types
A Racket value is represented by a pointer-sized value. The low bits
of the value indicate the encoding that it uses. For example, two (on
32-bit platform) or three (on 64-bit platforms) low bits indicates a
fixnum encoding, while a one low bit and zero second-lowest bit
indicates a pair whose address in memory is specified by the other
bits.
The C type for a Racket value is ptr. For most Racket types, a
constructor is provided for creating values of the type. For example,
Scons takes two ptr values and returns the cons
of the values as a new ptr value. In addition to providing
constructors, Racket defines several global constant Racket values,
such as Strue for #t.
3.1 Global Constants
There are six global constants:
3.2 Value Functions
Many of these functions are actually macros.
Predicates to recognize different kinds of Racket values, such as
fixnums, characters, the empty list, etc. The Srecord predicate
recognizes structures, but some built-in Racket datatypes are also
implemented as records.
Returns a Racket integer value, where i must fit in a fixnum.
Returns an integer value for different conversions from C, where the
result is allocated as a bignum if necessary to hold the value.
Converts a Racket fixnum to a C integer.
Converts a Racket integer (possibly a bignum) to a C integer, assuming
that the integer fits in the return type.
Returns a Racket flonum value.
Converts a Racket flonum value to a C floating-point number.
Returns a Racket character value. The ch value must be a legal
Unicode code point (and not a surrogate, for example). All characters
are represented by constant values.
Returns the Unicode code point for the Racket character ch.
ptr | | Scons | ( | ptr car, | | | | | ptr cdr) |
|
Extracts the
car or
cdr of a pair.
Returns the interned symbol whose name matches str.
Returns the Racket immutable string value for the Racket symbol
sym.
Allocates a fresh Racket mutable string with len characters. The
content of the string is either all chs when ch is
provided or unspecified otherwise.
Allocates a fresh Racket mutable string with the content of
str.
If
len is not provided,
str must be nul-terminated.
In the case of
Sstring_utf8,
str is decoded as
UTF-8, otherwise it is decided as Latin-1.
Returns the length of the string str.
Returns the ith Racket character of the string str.
Installs ch as the ith Racket character of the string str.
Allocates a fresh mutable
vector of length
len and with
v initially in every slot.
Returns the length of the vector vec.
Returns the ith element of the vector vec.
Installs v as the ith element of the vector vec.
Allocates a fresh mutable
fxvector of
length
len and with
v initially in every slot.
Returns the length of the fxvector vec.
Returns the ith fixnum of the fxvector vec.
Installs the fixnum v as the ith element of the fxvector
vec.
Allocates a fresh mutable
byte string of
length
len and with
byte initially in every slot.
Returns the length of the byte string bstr.
Returns the ith byte of the byte string bstr.
Installs byte as the ith byte of the byte string bstr.
Returns a pointer to the start of the bytes for the byte string bstr.
Allocates a fresh mutable
box containing
v.
Extract the content of the box bx.
Installs v as the content of the box bx.