On Sun, May 23, 2010 at 08:44:42PM +0100, Chris Cannam
wrote:
On Sun, May 23, 2010 at 9:41 AM, torbenh
<torbenh(a)gmx.de> wrote:
but i find the equivalen c++ easier to read.
assuming we have a proper modern c++ osc lib:
boost::unique_future<OscMsg>
osc_recv (OscPeer peer, std::string path)
{
boost::shared_ptr< boost::promise<OscMsg> > spromise( new
boost::promise<OscMsg> )
peer.add_handler( path, [=]( OscMsg msg )
{
[...]
Is this C++0xthingy?
I have to say this combination of Boost plus Weird Stuff From The
Future is no more readable to me (as a long-time C++ programmer) than
the Clojure example. It looks neat, but I'm pretty sure it's
accessible to you only because it's what you've spent the time with
recently.
I find this sort of thing absolutely beyond comprehension.
It's impossible to understand without knowing the boost::
abstractions, templates and god knows what else.
IMNSHO, the way any software works should be understandable by
a) knowing the language, b) reading the code, at least up to the
point that the reader can have an good idea of the big picture,
of data structures and control flow, only excluding application
domain specific details which require special expertise anyway.
If libraries are used to somehow extend the language rather for
encapsulating application domain specific algorithms, the net
result is code that is utterly unreadable to anyone who happens
not to use the same libraries. This is true for libs such as STL
and to a larger degree, boost.
Again IMNSHO, a programming language should be used 'as is',
without trying to extend it or introduce concepts that are
not part of it ('shared_ptr', 'promise' (whatever that means),
'spromise' (whatever that means), etc.). All the rest is just
obfusciation, and useful only to some niche of 'believers'.
the code is c++0x, which gcc-4.5 already handles.
i just used the boost stuff, because i hadnt noticed
that the promise future stuff is already in gcc-4.5 std:: namesapace.
shared_ptr is a std:: since gcc-4.3
basically the gcc guys are a bit slow with moving stuff thats already in
boost into the std namespace, since thats not really important.
and i really consider STL part of C++
so this is usage of c++0x "as is"
you might argue that its not set in stone yet, and *could* change a bit.
but its currently implemented. and the changes would be really small.
--
torben Hohn