www.delorie.com/gnu/docs/kawa/kawa_77.html   search  
 
Buy GNU books!


Kawa, the Java-based Scheme system

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.4 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 section 10.5 Accessing fields of Java objects) 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.

Syntax: primitive-get-field class fname ftype
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.

Syntax: primitive-set-field class fname ftype
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.)

Syntax: primitive-get-static class fname ftype
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.

Syntax: primitive-set-static class fname ftype
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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003