Crate pumpkinscript [] [src]

PumpkinScript

PumpkinScript is a minimalistic concatenative, stack-based language inspired by Forth.

It is used in PumpkinDB to operate a low-level database "virtual machine" — to manipulate, record and retrieve data.

This is an ultimate gateway to flexibility in how PumpkinDB can operate, what formats can it support, etc.

Reasoning

Why is it important?

In previous incarnations (or, rather, inspirations) of PumpkinDB much more rigid structures, formats and encoding were established as a prerequisite for using it, unnecessarily limiting the applicability and appeal of the technology and ideas behind it. For example, one had to buy into ELF, UUID-based event identification and HLC-based timestamps.

So it was deemed to be important to lift this kind of restrictions in PumpkinDB. But how do we support all the formats without knowing what they are?

What if there was a way to describe how data should be processed, for example, for indexing — in a compact, unambiguous and composable form? Or even for recording data itself? Well, that's where the idea to use something like a Forth-like script was born.

Instead of devising custom protocols for talking to PumpkinDB, the protocol of communication has become a pipeline to a script executor.

So, for example, a command/events set can be recorded with something like this (not an actual script, below is pseudocode):

<command id> <command payload> JOURNAL <event id> <event payload> JOURNAL

This offers us enormous extension and flexibility capabilities. To name a few:

  • Low-level imperative querying (as a foundation for declarative queries)
  • Indexing filters
  • Subscription filters

Features

  • Binary and text (human readable & writable) forms
  • No types, just byte arrays
  • Dynamic code evaluation
  • Zero-copy interpretation (where feasible; currently does not apply to the most important part, the storage itself as transactional model of LMDB precludes us from carrying these references outside of the scope of the transaction)

Reexports

pub use self::binparser::parse as parse_bin;
pub use self::textparser::parse;
pub use self::encodables::Encodable;
pub use self::encodables::Instruction;
pub use self::encodables::InstructionRef;
pub use self::encodables::Closure;
pub use self::encodables::Receivable;

Modules

binparser
encodables
textparser

Macros

write_size
write_size_header
write_size_into_slice

Enums

ParseError

Parse-related error

ParseResult

Holds the result of parsing functions

Traits

Packable
Unpackable

Functions

offset_by_size

Type Definitions

Program