Previous Next Contents

4. Virtual protocol

ColdStore has been designed to permit the inclusion of new Basetypes. A Basetype is any C++ object which has been interfaced to a ColdStore interpreter by means of the Data C++ object.

The C++ Data object provides a set of virtual methods (modelled on Python's) which any Concrete Protocol may call on any instance of any objects stored by ColdStore.

Data also provides for the instantiation of C++ objects into ColdStore persistent heap. In particular, virtual methods defined on a C++ object are guaranteed to be available to C++ objects instantiated within the persistent heap, so long as those objects follow the Virtual Protocol.

4.1 Structural Operators

virtual Slot hash(Error *&err)

The object's hash as an encoded integer

virtual Slot truth(Error *&err)

The object's truth value

virtual Slot toliteral(Error *&err)

The object as a literal

virtual Slot toconstruct(Error *&err)

Constructor args to recreate object

virtual Slot order(Slot &arg, Error *&err)

1,0,-1 depending on order

static Slot parse(Slot &arg, Error *&err)

construct from literal

static Slot construct(Slot &arg, Error &*err)

construct from constructor args

4.2 Arithmetic Operators

The following operators are intended to provide `arithmetic' operations on Data. Compilers are able to generate opcodes in response to conventional infix arithmetic operator orthography, which map to elements of their Concrete Protocol which subsequently invoke these operator virtuals.

Nothing is intended to prevent an object from interpreting a given conventional sign in an ideosyncratic manner, for example, String might interpret the operator "+" as a concatenation operation.

virtual Slot positive(Error *&err)

monadic `+', absolute value

virtual Slot negative(Error *&err)

monadic `-', negative absolute value

virtual Slot add(Slot &arg, Error *&err)

dyadic `+', add

virtual Slot subtract(Slot &arg, Error *&err)

dyadic `-', subtract

virtual Slot multiply(Slot &arg, Error *&err)

dyadic `*', multiply

virtual Slot divide(Slot &arg, Error *&err)

dyadic '/', divide

virtual Slot modulo(Slot &arg, Error *&err)

dyadic '%', modulo

4.3 Bitwise Operators

virtual Slot invert(Error *&err)

unary '~', invert

virtual Slot and(Slot &arg, Error *&err)

dyadic '&', bitwise and

virtual Slot xor(Slot &arg, Error *&err)

dyadic '^', bitwise xor

virtual Slot or(Slot &arg, Error *&err)

dyadic '|', bitwise or

virtual Slot lshift(Slot &arg, Error *&err)

dyadic '<<', left shift

virtual Slot rshift(Slot &arg, Error *&err)

dyadic '>>', right shift

4.4 Sequence Operators

virtual Slot length(Error *&err)

length of the object, considered as a sequence

virtual Slot concat(Slot &arg, Error *&err)

concatenate two sequences

virtual Slot index(Slot &index, Error *&err)

dyadic `[]', index

virtual Slot in(Slot &search, Error *&err)

dyadic `in', matching subrange

virtual Slot del(Slot &range, Error *&err)

delete subrange

virtual Slot assign(Slot &range, Slot &value, Error *&err)

replace subrange

virtual Slot iterator(Error *&err, void *allocator)

return an iterator

4.5 Map Operators

virtual Slot items(Error *&err)

return map as sequence

4.6 Callable Operators

virtual Slot call(Error *&err)

call object (Method, Builtin)


Previous Next Contents