Next: , Previous: Data Types, Up: Data Types


6.1.1 Immediates

An immediate is a data type contained in type SCM (long int). The type codes distinguishing immediate types from each other vary in length, but reside in the low order bits.

— Macro: IMP x
— Macro: NIMP x

Return non-zero if the SCM object x is an immediate or non-immediate type, respectively.

— Immediate: inum

immediate 30 bit signed integer. An INUM is flagged by a 1 in the second to low order bit position. The high order 30 bits are used for the integer's value.

— Macro: INUMP x
— Macro: NINUMP x

Return non-zero if the SCM x is an immediate integer or not an immediate integer, respectively.

— Macro: INUM x

Returns the C long integer corresponding to SCM x.

— Macro: MAKINUM x

Returns the SCM inum corresponding to C long integer x.

— Immediate Constant: INUM0

is equivalent to MAKINUM(0).

Computations on INUMs are performed by converting the arguments to C integers (by a shift), operating on the integers, and converting the result to an inum. The result is checked for overflow by converting back to integer and checking the reverse operation.

The shifts used for conversion need to be signed shifts. If the C implementation does not support signed right shift this fact is detected in a #if statement in scmfig.h and a signed right shift, SRS, is constructed in terms of unsigned right shift.

— Immediate: ichr

characters.

— Macro: ICHRP x

Return non-zero if the SCM object x is a character.

— Macro: ICHR x

Returns corresponding unsigned char.

— Macro: MAKICHR x

Given char x, returns SCM character.

— Immediate: iflags

These are frequently used immediate constants.

— Immediate Constant: SCM BOOL_T

#t

— Immediate Constant: SCM BOOL_F

#f

— Immediate Constant: SCM EOL

(). If SICP is #defined, EOL is #defined to be identical with BOOL_F. In this case, both print as #f.

— Immediate Constant: SCM EOF_VAL

end of file token, #<eof>.

— Immediate Constant: SCM UNDEFINED

#<undefined> used for variables which have not been defined and absent optional arguments.

— Immediate Constant: SCM UNSPECIFIED

#<unspecified> is returned for those procedures whose return values are not specified.

— Macro: IFLAGP n

Returns non-zero if n is an ispcsym, isym or iflag.

— Macro: ISYMP n

Returns non-zero if n is an ispcsym or isym.

— Macro: ISYMNUM n

Given ispcsym, isym, or iflag n, returns its index in the C array isymnames[].

— Macro: ISYMCHARS n

Given ispcsym, isym, or iflag n, returns its char * representation (from isymnames[]).

— Macro: MAKSPCSYM n

Returns SCM ispcsym n.

— Macro: MAKISYM n

Returns SCM iisym n.

— Macro: MAKIFLAG n

Returns SCM iflag n.

— Variable: isymnames

An array of strings containing the external representations of all the ispcsym, isym, and iflag immediates. Defined in repl.c.

— Constant: NUM_ISPCSYM
— Constant: NUM_ISYMS

The number of ispcsyms and ispcsyms+isyms, respectively. Defined in scm.h.

— Immediate: isym

and, begin, case, cond, define, do, if, lambda, let, let*, letrec, or, quote, set!, #f, #t, #<undefined>, #<eof>, (), and #<unspecified>. — CAR Immediate: ispcsym

special symbols: syntax-checked versions of first 14 isyms

— CAR Immediate: iloc

indexes to a variable's location in environment

— CAR Immediate: gloc

pointer to a symbol's value cell

— Immediate: CELLPTR

pointer to a cell (not really an immediate type, but here for completeness). Since cells are always 8 byte aligned, a pointer to a cell has the low order 3 bits 0.

There is one exception to this rule, CAR Immediates, described next.

A CAR Immediate is an Immediate point which can only occur in the CARs of evaluated code (as a result of ceval's memoization process).