Re: [LAD] Looking for an introduction to rt programming with a gui

From: torbenh <torbenh@email-addr-hidden>
Date: Mon May 24 2010 - 13:48:58 EEST

On Sun, May 23, 2010 at 10:53:59PM -0400, Paul Davis wrote:
> On Sun, May 23, 2010 at 10:03 PM, Joshua D. Boyd <jdboyd@email-addr-hidden> wrote:
>
> >
> > I think it isn't difficult to read because it is C++ or Boost. It is
> > difficult to read because it involves concepts like promises and futures,
> > which are advanced topics that a lot of people (myself included) aren't
> > adequately familiar with (at least not without referring to a cheat sheet).
> > If we rewrote that with C types using a C type future/promise system, I'm
> > not sure it would be any easier to read for those of us who don't
> > intuitively grok promises and futures.
> >
> >
> what he said. we can extend this to a lot of boost-covered stuff. a C
> implementation of boost::optional would be similarly opaque and clumsy, i
> think.
>
> i also can't begin to imagine how to implement scoped-lifetime objects in C.
> even without exceptions (which admittedly do cause some conceptual pain in
> C++), the ability to know that wherever you return from within a function,
> relevant local objects will be cleaned up has a significant simplifying
> effect on the design of a function.
>
> so yes, you can certainly get along without these ideas and write very
> sophisticated software. the issue is really about whether you want to. when
> i went to write a functor class a few months ago, i got about 90% of the way
> there in a few hours. then i went and read the boost headers and realized
> there was an entire universe of semantic details that i was overlooking and
> that to get all the way "there" would take me weeks, assuming i ever got
> there. so i could (a) do without functors or (b) use the boost
> implementation. i chose (a).

yeah. the functors are a point where c++ needs a language extension.
but the c++0x lambda is that.

and it really makes closures pretty painless and straight forward.
i dont really understand why a lambda is some obscure type that needs to
be converted to a std::function if you want to store them in a
container (this sounds a bit like java before generics ;)

but this probably to allow compiler to optimize something like this:

int total = 0;
std::vector<int> vec;

auto sum_up = [&](int v) { total += v; };

std::for_each( vec.begin(), vec.end(), sum_up );

std::cout << total;

-- 
torben Hohn
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Mon May 24 16:15:02 2010

This archive was generated by hypermail 2.1.8 : Mon May 24 2010 - 16:15:03 EEST