Up: descriptors other [Contents][Index]
The following syntactic bindings are exported by the library
(vicare system type-descriptors)
.
Name of type descriptors representing interfaces. It has the following fields:
type-name
A symbol representing the name of this interface type.
uid
A symbol acting as unique identifier associated to this type descriptor.
parent-type-descriptor
An instance of <interface-type-descr>
representing the parent of
this interface–type; #f
if this interface–type has no parent.
implemented-interface-uids
A list of symbols representing the UIDs of the interfaces implemented by this interface–type.
method-prototype-names
A list of symbols representing the names of public methods that must be provided by object–types implementing this interface.
method-retriever
A function that retrieves method implementation functions given the name of a method as symbol.
Build and return a new instance of <interface-type-descr>
.
Return #t
if obj is an instance of
<interface-type-descr>
; otherwise return #f
.
Accessors for the fields of <interface-type-descr>
instances.
The argument descr must be an object–type’s run–time descriptor.
Return #t
if the object–type implements the interface–type whose
UID is interface-uid; otherwise return #f
.
Usage example, a record–type implements an interface–type:
(define-interface-type <IOne> (nongenerative dummy:<IOne>) (method-prototype doit (lambda (<string>) => (<number>)))) (define-record-type <blue> (implements <IOne>) (method ({doit <number>} {S <string>}) 1)) (object-type-implements-interface? 'dummy:<IOne> (record-type-descriptor <blue>)) ⇒ #t (object-type-implements-interface? (car (type-unique-identifiers <IOne>)) (record-type-descriptor <blue>)) ⇒ #t (define O (new <blue>)) (is-a? O <IOne>) ⇒ #t (is-a? (cast-signature (<top>) O) <IOne>) ⇒ #t
Another usage example, a record–type implements an interface–type and its parent:
(define-interface-type <IOne> (method-prototype one (lambda (<string>) => (<number>)))) (define-interface-type <ITwo> (parent <IOne>) (method-prototype two (lambda (<string>) => (<number>)))) (define-record-type <blue> (implements <ITwo>) (method ({one <number>} {S <string>}) 1) (method ({two <number>} {S <string>}) 1)) (object-type-implements-interface? (car (type-unique-identifiers <IOne>)) (record-type-descriptor <blue>)) ⇒ #t (object-type-implements-interface? (car (type-unique-identifiers <ITwo>)) (record-type-descriptor <blue>)) ⇒ #t (define O (new <blue>)) (is-a? O <IOne>) ⇒ #t (is-a? O <ITwo>) ⇒ #t (is-a? (cast-signature (<top>) O) <IOne>) ⇒ #t (is-a? (cast-signature (<top>) O) <ITwo>) ⇒ #t
Up: descriptors other [Contents][Index]