1 Language Model
2 Syntactic Forms
3 Datatypes
4 Structures
5 Classes and Objects
6 Units
7 Contracts
8 Pattern Matching
9 Control Flow
10 Concurrency
11 Macros
12 Input and Output
13 Reflection and Security
14 Operating System
15 Memory Management
16 Running PLT Scheme
Bibliography
Index
On this page:
object?
class?
interface?
generic?
object=?
object->vector
class->interface
object-interface
is-a?
subclass?
implementation?
interface-extension?
method-in-interface?
interface->method-names
object-method-arity-includes?
field-names
object-info
class-info
exn: fail: object
Version: 4.0.2

 

5.9 Object, Class, and Interface Utilities

(object? v)  boolean?

  v : any/c

Returns #t if v is an object, #f otherwise.

(class? v)  boolean?

  v : any/c

Returns #t if v is a class, #f otherwise.

(interface? v)  boolean?

  v : any/c

Returns #t if v is an interface, #f otherwise.

(generic? v)  boolean?

  v : any/c

Returns #t if v is a generic, #f otherwise.

(object=? a b)  eq?

  a : object?

  b : object?

Determines if two objects are the same object, or not; this procedure uses "eq?", but also works properly with contracts.

(object->vector object [opaque-v])  vector?

  object : object?

  opaque-v : any/c = #f

Returns a vector representing object that shows its inspectable fields, analogous to struct->vector.

(class->interface class)  interface?

  class : class?

Returns the interface implicitly defined by class.

(object-interface object)  interface?

  object : object?

Returns the interface implicitly defined by the class of object.

(is-a? v type)  boolean?

  v : any/c

  type : (or/c interface? class?)

Returns #t if v is an instance of a class type or a class that implements an interface type, #f otherwise.

(subclass? v class)  boolean?

  v : any/c

  class : class?

Returns #t if v is a class derived from (or equal to) class, #f otherwise.

(implementation? v interface)  boolean?

  v : any/c

  interface : interface?

Returns #t if v is a class that implements interface, #f otherwise.

(interface-extension? v interface)  boolean?

  v : any/c

  interface : interface?

Returns #t if v is an interface that extends interface, #f otherwise.

(method-in-interface? sym interface)  boolean?

  sym : symbol?

  interface : interface?

Returns #t if interface (or any of its ancestor interfaces) includes a member with the name sym, #f otherwise.

(interface->method-names interface)  (listof symbol?)

  interface : interface?

Returns a list of symbols for the method names in interface, including methods inherited from superinterfaces, but not including methods whose names are local (i.e., declared with define-local-member-names).

(object-method-arity-includes?

 

object

 

 

 

 

 

 

sym

 

 

 

 

 

 

cnt)

 

 

boolean?

  object : object?

  sym : symbol?

  cnt : nonnegative-exact-integer?

Returns #t if object has a method named sym that accepts cnt arguments, #f otherwise.

(field-names object)  (listof symbol?)

  object : object?

Returns a list of all of the names of the fields bound in object, including fields inherited from superinterfaces, but not including fields whose names are local (i.e., declared with define-local-member-names).

(object-info object)

 

 

(or/c class? false/c)

 

boolean?

  object : any/c

Returns two values, analogous to the return values of struct-info: K%

(class-info class)

 

 

symbol?

nonnegative-exact-integer?

(listof symbol?)

(any/c nonnegative-exact-integer? . -> . any/c)

(any/c nonnegative-exact-integer? any/c . -> . any/c)

(or/c class? false/c)

boolean?

  class : class?

Returns seven values, analogous to the return values of struct-type-info:

(struct

 

(exn:fail:object exn:fail)

 

())

Raised for class-related failures, such as attempting to call a method that is not supplied by an object.