Comments (1)
The usual way of coding in message oriented programming is always pattern -> behavior. And what you do is to hide the pattern.
If you are worry about, that your message format might be change in the future, just use a structure instead of "structured tuples" where you're using atoms for context informations.
See the announce_example_1 from libcppa (stripped):
#include <utility>
#include <iostream>
#include "cppa/cppa.hpp"
using std::cout;
using std::endl;
using namespace cppa;
struct foo
{
int a;
int b;
};
bool operator==(const foo& lhs, const foo& rhs)
{
return lhs.a == rhs.a
&& lhs.b == rhs.b;
}
int main(int, char**)
{
announce<foo>(&foo::a, &foo::b);
send(self(), foo{1,2});
receive_loop
(
on<foo>() >> [](const foo& val)
{
cout << "foo("
<< val.a << ","
<< val.b << ")"
<< endl;
}
);
return 0;
}
If foo changes in the future, it does not affect "old" code and if it does (e.g. if you access a member that's deleted from the class), your compiler will tell you. This is what you meant by "type safety", I guess.
The downside of this is, that you can't match against member values of foo, because the C++ type system does not allow for something similar to case classes like Scala. If you try to emulate case classes in C++ you end up coding hundreds of lines of precompiler statements, making your source code just ... bad (this is why I discarded acedia, btw.).
The structure you're using has to fulfill two requirements: it has to provide operator== and you have to tell libcppa how to serialize it (this is what announce does).
from actor-framework.
Related Issues (20)
- Allow setting a weight for each item transported in a flow
- Implement new mail API HOT 1
- Deprecate `others` utility
- High-level caf-net primitive for custom binary protocols
- Add blocking member functions to futures
- Add a version for response promises that accept an `expected`
- Passing linked flags to stateful actors is broken
- Runtime error with scheduled actors and timeouts
- Exception when nesting same blocks inside BDD outlines
- Test `caf.flow.generation` unstable on CI HOT 3
- Implement new `set_idle_handler`
- Properly implement await semantics in actor shells
- Support splitting and UTF-8 conversions in flow::byte
- Regular sections recognize <arg> syntax
- Deprecate legacy APIs for 1.0
- Error when calling a function_view with an terminated actor
- `uri::can_parse` rejects username and password
- Simplify the error class HOT 2
- Implement on-backpressure-buffer operator
- Documentation update for 1.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from actor-framework.