why there are no multimethods in c++? [closed]

谁都会走 提交于 2019-12-05 01:14:55

Straight from the horse's mouth:

"I rejected multi-methods with regret, because I liked the idea, but couldn't find an acceptable form under which to accept it."

Bjarne Stroustrup, The Design and Evolution of C++ (p297)

And later:

"Multi-methods is one of the interesting what-ifs of C++. Could I have designed and implemented them well enough at the time? [...] What other work might have been left undone to provide the time to design and implement multi-methods?"

(p298f)

In general, whenever you feel the urge to know why some particular C++ feature was implemented, or was not implemented, or was implemented the way it is now, and if that feature pre-dates the standardization, you want to read D&E.

As Bjarne has pointed out a number of times, when people criticize C++, it usually runs something like: "C++ is too big, too complex, has too many features, and it's too hard to learn -- you should really work at making it smaller and simpler. Oh, and while you're working on that I also have this really great idea for a killer feature that you should add!"

Just because it could be done doesn't mean it's a problem that it wasn't done. One criticism of C++ is along the lines of "Stroustrup took everything anyone had heard of, and tried to include it."

Plus, as Raymond Chen says, "Every feature starts off with -100 points." That is, before you ask why C++ doesn't have these things, you should explain in detail why it needs them. Otherwise your feature stays in negative territory, due to the costs associated with it.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!