Hello, Michael.
Thursday, February 5, 2009 at 11:09:49 PM you wrote:
MF> We're getting off-topic, but I couldn't resist.
We are talking about namespaces, so I think it is good idea to look
around. :)
MF> What happens when I do:
MF> using System.Drawing;
MF> using Microsoft.XNA.Framework;
MF> Point p = new Point(); // Doh!
Good example. But... You have to do something very _special_ if you
want to get the same result inside only 'System' namespace. Isn't it?
I mean what you can use unqualified ids and usings in most cases
without any errors from the compilator _when you use only standard
facilities_.
MF> You see, these problems occur in C# too, and the same answer (from
MF> C++) is given as to how to correct the issue. Make a namespace alias,
MF> or use full qualification.
MF> If you want to use boost, use boost::. If you want to use the STD
MF> library, use std::.
Perfectly! What you can say about following pieces of code:
std::vector<std::shared_ptr<SomeClass>> vec;
std::for_each(vec.begin(), vec.end(), std::bind(&std::shared_ptr<SomeClass>::get, std::placeholders::_1, std::bind(&SomeClass::foo, std::placeholders::_1, 10)));
and
vector<shared_ptr<SomeClass>> vec;
for_each(vec.begin(), vec.end(), bind(&shared_ptr<SomeClass>::get, _1, bind(&SomeClass::foo, _1, 10)));
from the readness point of view?
Assume what I place std and std::placeholders namespace into new namespace ('slib'):
slib::vector<slib::shared_ptr<SomeClass>> vec;
slib::for_each(vec.begin(), vec.end(), slib::bind(&slib::shared_ptr<SomeClass>::get, slib::_1, slib::bind(&SomeClass::foo, slib::_1, 10)));
Is it quite readable or your eyes are seeing only 'slib' and '::'? Is _it_ improving of 'code readness'? And you are offering C++ beginners to use such coding style. It is good style, but I'm absolutely sure what beginners (even with C# or Java experience) say you something ugly and then return to C# or Java. :)
--
Best Regards,
Sergey mailto:flex_ferrum@artberg.ru