Akim Demaille wrote:
> > I haven't done coroutines, but threads, and of course, everything
> > that's exposed there, I make as const as possible. But that doesn't
> > usually include local variables.
>
> Local variables can be captured by lambdas and passed to coroutines.
That's why I cautioned my statement with "usually". ;)
> In fact, I enjoyed so much 'const' on my variables, that I started
> using a lot 'IIFE' (immediately invoked function expressions) to
> be able to have this property more often. E.g.
>
> const auto context = [&]
> {
> auto res = elle::serialization::Context{};
> res.set<Doughnut*>(&this->doughnut());
> res.set<elle::Version>(
> elle_serialization_version(this->doughnut().version()));
> return res;
> }();
I've used this rarely so far, mostly for member-initialization in
constructors (where something like it is necessary if they don't
have default constructors), only occasionally for plain local
variables.
> I agree short lived entities should have short names. That's
> actually one benefit (the only one?) to have *.h and *.c files:
> *.h files can expose intelligent meaningful names, while *.c can
> use short names.
I think we could still do that in a single source file with a little
discipline. I'd love to have real modules in C++ (one day ...).
Regards,
Frank