Low-level Operations on Object Fields
The following macros evaluate to procedures that can be used to
access or change the fields of objects or static fields.
The compiler can inline each to a single bytecode instruction
(not counting type conversion).
These macros are deprecated.
The fields
and static-field
functions
(see Field operations) are easier to use, more powerful, and
just as efficient. (One exception is for primitive-set-static
;
while its functionality can be expressed using
(set! (static-field ...) ...)
, that idiom is currently
less efficient.) Also, the high-level functions currently do
not provide access to private fields.
primitive-get-field class fname ftype
|
Syntax |
Use this to access a field named fname having type type in
class class. Evaluates to a new one-argument procedure,
whose argument is a reference to an object of the specified class.
Calling that procedure returns the value of the specified field.
|
primitive-set-field class fname ftype
|
Syntax |
Use this to change a field named fname having type type in
class class. Evaluates to a new two-argument procedure,
whose first argument is a reference to an object of the
specified class, and the second argument is the new value.
Calling that procedure sets the field to the specified value.
(This macro's name does not end in a ! , because it does not actually
set the field. Rather, it returns a function for setting the field.)
|
primitive-get-static class fname ftype
|
Syntax |
Like primitive-get-field , but used to access static fields.
Returns a zero-argument function, which when called returns
the value of the static field.
|
primitive-set-static class fname ftype
|
Syntax |
Like primitive-set-field , but used to modify static fields.
Returns a one-argument function, which when called sets the
value of the static field to the argument.
|