ucbrise / fluent-old

Bloom + C++
17 stars 3 forks source link

Added Const Operator #85

Closed mwhittaker closed 7 years ago

mwhittaker commented 7 years ago

Consider the following snippet of a chat client:

std::vector<string, string, string> connect_tuple = {
  std::make_tuple("...", "...", "...")
};

fluent::fluent<...>(...)
  .stdin()
  .stdout()
  .channel<string, string, string>("connect", {{"saddr", "caddr", "nickname"}})
  .channel<string, string>("mcast", {{"addr", "msg"}})
  .RegisterBootstrapRules([&](auto&, auto&, auto& connect, auto&) {
    using namespace fluent::infix;
    auto iterable = ra::make_iterable("connect_tuple", &connect_tuple);
    return std::make_tuple(connect <= iterable);
  })

Initially, the chat client has to register with the chat server by sending it a tuple on the connect channel. It does so by creating a bootstrap rule which forwards connect_tuple into connect. Later, if we ask for the lineage of the tuple in connect, it says its in the connect_tuple collection, but connect_tuple isn't really a collection at all. connect_tuple acts more like a constant in a query than a full-fledged collection. We introduce a new const operator which acts like a constant in a query and doesn't produce lineage.