[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++ preferences (was: RFC: lalr1.cc: support move semantics)
From: |
Frank Heckenbach |
Subject: |
Re: C++ preferences (was: RFC: lalr1.cc: support move semantics) |
Date: |
Sat, 15 Sep 2018 15:27:41 +0200 |
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
- Re: C++ preferences (was: RFC: lalr1.cc: support move semantics), (continued)
- Re: C++ preferences (was: RFC: lalr1.cc: support move semantics), Frank Heckenbach, 2018/09/12
- Re: C++ preferences (was: RFC: lalr1.cc: support move semantics), Akim Demaille, 2018/09/13
- Re: C++ preferences, Hans Åberg, 2018/09/13
- Re: C++ preferences, Akim Demaille, 2018/09/13
- Re: C++ preferences, Hans Åberg, 2018/09/13
- Re: C++ preferences, Akim Demaille, 2018/09/13
- Re: C++ preferences, Hans Åberg, 2018/09/13
- Re: C++ preferences, Hans Åberg, 2018/09/13
- Re: C++ preferences (was: RFC: lalr1.cc: support move semantics), Frank Heckenbach, 2018/09/13
- Re: C++ preferences (was: RFC: lalr1.cc: support move semantics), Akim Demaille, 2018/09/15
- Re: C++ preferences (was: RFC: lalr1.cc: support move semantics),
Frank Heckenbach <=
- Re: C++ preferences (was: RFC: lalr1.cc: support move semantics), Akim Demaille, 2018/09/15
- Re: C++ preferences (was: RFC: lalr1.cc: support move semantics), Frank Heckenbach, 2018/09/15
- Re: C++ preferences (was: RFC: lalr1.cc: support move semantics), Akim Demaille, 2018/09/16
- Re: C++ preferences (was: RFC: lalr1.cc: support move semantics), Hans Åberg, 2018/09/13
- Re: C++ preferences (was: RFC: lalr1.cc: support move semantics), Akim Demaille, 2018/09/13
- Re: C++ preferences, Hans Åberg, 2018/09/13