pmt

Polymorphic Types.

The type can really be used to store anything, but also has simple conversion methods for common data types such as bool, long, or a vector.

The polymorphic type simplifies message passing between blocks, as all of the data is of the same type, including the message. Tags also use PMTs as data type, so a stream tag can be of any logical data type. In a sense, PMTs are a way to extend C++’ strict typing with something more flexible.

The PMT library supports the following major types: bool, symbol (string), integer, real, complex, null, pair, list, vector, dict, uniform_vector, any (boost::any cast)

Boolean

pmt.is_bool Return true if obj is #t or #f, else return false.
pmt.is_true Return false if obj is #f, else return true.
pmt.is_false Return true if obj is #f, else return true.
pmt.from_bool Return #f is val is false, else return #t.
pmt.to_bool Return true if val is pmt::True, return false when val is pmt::PMT_F,.

Symbols

pmt.is_symbol Return true if obj is a symbol, else false.
pmt.string_to_symbol Return the symbol whose name is .
pmt.symbol_to_string If a symbol, return the name of the symbol as a string.
pmt.intern Alias for pmt_string_to_symbol.

Numbers

pmt.is_number Return true if obj is any kind of number, else false.

Integers

pmt.is_integer Return true if is an integer number, else false.
pmt.to_long Convert pmt to long if possible.
pmt.from_long Return the pmt value that represents the integer .

uint64_t

pmt.is_uint64 Return true if is an uint64 number, else false.
pmt.to_uint64 Convert pmt to uint64 if possible.
pmt.from_uint64 Return the pmt value that represents the uint64 .

Reals

pmt.is_real
pmt.to_double Convert pmt to double if possible.
pmt.from_double Return the pmt value that represents double .

Complex

pmt.is_complex return true if is a complex number, false otherwise.
pmt.to_complex If is complex, real or integer, return the closest complex<double>.
pmt.from_complex Return a complex number constructed of the given real and imaginary parts.
pmt.make_rectangular Return a complex number constructed of the given real and imaginary parts.

Pairs

pmt.is_pair Return true if is a pair, else false.
pmt.cons Return a newly allocated pair whose car is and whose cdr is .
pmt.car If is a pair, return the car of the , otherwise raise wrong_type.
pmt.cdr If is a pair, return the cdr of the , otherwise raise wrong_type.
pmt.set_car Stores in the car field of .
pmt.set_cdr Stores in the cdr field of .
pmt.caar
pmt.cadddr
pmt.caddr
pmt.cadr
pmt.cdar
pmt.cddr

Tuples

pmt.is_tuple Return true if is a tuple, othewise false.
pmt.make_tuple make_tuple(swig_int_ptr e0) -> swig_int_ptr
pmt.tuple_ref Return the contents of position of .
pmt.to_tuple If is a vector or proper list, return a tuple containing the elements of x

Vectors

pmt.is_vector Return true if is a vector, othewise false.
pmt.make_vector Make a vector of length , with initial values set to .
pmt.vector_ref Return the contents of position of .
pmt.vector_set Store in position .
pmt.vector_fill Store in every position of .

BLOBs

pmt.is_blob Return true if is a blob, othewise false.
pmt.make_blob Make a blob given a pointer and length in bytes.
pmt.blob_data Return a pointer to the blob’s data.
pmt.blob_length Return the blob’s length in bytes.

Dictionary

pmt.is_dict Return true if is a dictionary.
pmt.make_dict Make an empty dictionary.
pmt.dict_add Return a new dictionary with associated with .
pmt.dict_delete Return a new dictionary with removed.
pmt.dict_has_key Return true if exists in .
pmt.dict_ref If exists in , return associated value; otherwise return .
pmt.dict_items Return list of (key .
pmt.dict_keys Return list of keys.
pmt.dict_values Return list of values.

Any

pmt.is_any Return true if is an any.
pmt.make_any make an any
pmt.any_ref Return underlying boost::any.
pmt.any_set Store in .

Message Accepter

pmt.is_msg_accepter Return true if is a msg_accepter.
pmt.make_msg_accepter make a msg_accepter
pmt.msg_accepter_ref Return underlying msg_accepter.

General Functions

pmt.eq Return true if x and y are the same object; otherwise return false.
pmt.equal pmt::equal recursively compares the contents of pairs and vectors, applying pmt::eqv on other objects such as numbers and symbols. pmt::equal may fail to terminate if its arguments are circular data structures.
pmt.eqv Return true if x and y should normally be regarded as the same object, else false.
pmt.length Return the number of elements in v.
pmt.assq Find the first pair in whose car field is and return that pair.
pmt.assv Find the first pair in whose car field is and return that pair.
pmt_assoc

Lists

pmt.map Apply element-wise to the elements of list and returns a list of the results, in order.
pmt.reverse reverse .
pmt.reverse_x destructively reverse .
pmt.acons (acons x y a) == (cons (cons x y) a)
pmt.nth locates element of
pmt.nthcdr returns the tail of that would be obtained by calling cdr times in succession.
pmt.memq Return the first sublist of whose car is .
pmt.memv Return the first sublist of whose car is .
pmt.member Return the first sublist of whose car is .
pmt.subsetp Return true if every element of appears in , and false otherwise.
pmt.list1 Return a list of length 1 containing .
pmt.list2 Return a list of length 2 containing , .
pmt.list3 Return a list of length 3 containing , , .
pmt.list4 Return a list of length 4 containing , , , .
pmt.list5 Return a list of length 5 containing , , , , .
pmt.list6 Return a list of length 6 containing , , , , , .
pmt.list_add Return with added to it.
pmt.list_rm Return with removed from it.
pmt.list_has Return bool of contains .

Read/Write

pmt.is_eof_object return true if obj is the EOF object, otherwise return false.
pmt.read read converts external representations of pmt objects into the objects themselves. Read returns the next object parsable from the given input port, updating port to point to the first character past the end of the external representation of the object.
pmt.write Write a written representation of to the given .
pmt.write_string Return a string representation of .

Serialize

pmt.serialize Write portable byte-serial representation of to .
pmt.deserialize Create obj from portable byte-serial representation.
pmt.dump_sizeof
pmt.serialize_str Provide a simple string generating interface to pmt’s serialize function.
pmt.deserialize_str Provide a simple string generating interface to pmt’s deserialize function.

Misc

pmt.is_null Return true if is the empty list, otherwise return false.
pmt.cvar

Constants

pmt.PMT_EOF Proxy of C++ boost::intrusive_ptr<(pmt::pmt_base)> class
pmt.PMT_EOF Proxy of C++ boost::intrusive_ptr<(pmt::pmt_base)> class
pmt.PMT_F Proxy of C++ boost::intrusive_ptr<(pmt::pmt_base)> class
pmt.PMT_NIL Proxy of C++ boost::intrusive_ptr<(pmt::pmt_base)> class
pmt.PMT_T Proxy of C++ boost::intrusive_ptr<(pmt::pmt_base)> class