Description Usage Arguments Value Slots The Prototype class Using the class See Also
A formal class to rigorously define prototypes of any R objects.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | Prototype(archetype, enclosure, constructor, ...)
## S4 method for signature 'missing,missing,missing'
Prototype(archetype, enclosure, constructor, ...)
## S4 method for signature 'ANY,missing,missing'
Prototype(archetype, enclosure, constructor, ...)
## S4 method for signature 'ANY,character,missing'
Prototype(archetype, enclosure, constructor, ...)
## S4 method for signature 'ANY,environment,missing'
Prototype(archetype, enclosure, constructor, ...)
## S4 method for signature 'ANY,character,character'
Prototype(archetype, enclosure, constructor, ...)
## S4 method for signature 'ANY,environment,character'
Prototype(archetype, enclosure, constructor, ...)
## S4 method for signature 'ANY,missing,call'
Prototype(archetype, enclosure, constructor, ...)
## S4 method for signature 'ANY,character,call'
Prototype(archetype, enclosure, constructor, ...)
## S4 method for signature 'ANY,environment,call'
Prototype(archetype, enclosure, constructor, ...)
## S4 method for signature 'Prototype'
show(object)
|
archetype |
any R object to be prototyped. |
enclosure |
an |
constructor |
a |
... |
further arguments used to construct a suitable call if
|
object |
a |
The constructor Prototype()
returns an object of class
Prototype
.
The show()
method returns NULL
invisibly. It is used for its-effect.
archetype
any R object. A representation of the prototype that conveys the object's class.
enclosure
an environment
in which the object's
class is defined or NULL
.
constructor
a call
that can be used to generate an object
of the same class as archetype
or NULL
.
Class Prototype
holds consistent prototypes of any R object. A
consistent prototype theoretically has three components:
a representation in R (here called an archetype);
an enclosure (the environment holding the arechetype's class definition);
a constructor function that generates the archetype.
The third component is needed because two different functions defined in the same enclosure can theoretically return two objects of the same class based on two different class definitions. In practice, this never happens, because it breaks R usual method dispatching mechanisms.
The API is intentionally kept minimal, since the class is mostly intended
to be used within class Schema
.
Create objects of class Prototype
through the constructor function
Prototype()
.
Validate instances of the class by using valid_prototype()
.
Test objects for class Prototype
with introspector function
is_prototype()
.
Extract slots from instances of the class with functions archetype()
,
enclosure()
and constructor()
.
Set new values to slots with functions archetype<-()
,
enclosure<-()
and constructor<-()
.
Methods for class Prototype
are implemented for generic functions
format()
and show()
.
Other Prototype:
Prototype-accessors
,
Prototype-validators
,
is_prototype()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.