9 ms·
cout << join(pm | transformed([](propMap::value_type pv){... I'm sorry, but as "succinct" as it is, this is basically an unreadable bullshit. Reminds me strong
by huhtenberg 14y ago
cout << join(pm | transformed([](propMap::value_type pv){...
I'm sorry, but as "succinct" as it is, this is basically an unreadable bullshit. Reminds me strongly of a macro abuse in C.
- daivd 14y agoIt is only unreadable bullshit the first time you read it. If you use ranges, filtered and transformed for these kinds of tasks, it looks idiomatic.
- morsch 14y agoYep. It looked idiomatic to me -- and I don't even know C++11! I don't care for the unqualified access to join and transformed, though, even if it is more Pythonesque.
- alpatters 14y agoyou might not like the syntax of this particular boost lib, but it bears no relation to macro abuse in C. For one it is strongly typed. Of course it is unreadable if you don't know C++ or boost range. But it is not more complex than a python map or filter with a lambda, if you don't know python.
- lmm 14y agoIt is visibly worse than python. '|' - I thought that was bitwise or? - rather than an (admittedly technical) English word like 'map' or 'filter' (and '<<' has the same problem). 'transformed([](pv){...})' may be necessary for compatibility, but the brackets are harder to follow than 'transformed(lambda pv: ...)'. And the type declaration as "propMap::value_type" is just noise - it doesn't tell the reader anything about what the actual type is, and it isn't necessary for static typechecking either (it would be optional in a modern statically typed language e.g. Scala).