为什么 c++ 中没有多方法?

发布于 2024-10-15 04:00:37 字数 675 浏览 6 评论 0原文

我读了很多关于如何在 C++ 中实现多方法的文章:

  1. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1529.html
  2. http://www.codeproject.com/KB/recipes/mmcppfcs.aspx
  3. http://lambda-the-ultimate.org/node/2590
  4. http://parasol.tamu.edu/people/peterp/omm/

为什么c++中没有multimethod?

为什么他们没有得到 C++ 标准的支持?

I read many article about how to implement multimethod in c++:

  1. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1529.html
  2. http://www.codeproject.com/KB/recipes/mmcppfcs.aspx
  3. http://lambda-the-ultimate.org/node/2590
  4. http://parasol.tamu.edu/people/peterp/omm/

why there are no multimethod in c++?

why do not they get supported by c++ standard?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

聽兲甴掵 2024-10-22 04:00:37

直接从马嘴里说出来:

“我遗憾地拒绝了多种方法,因为我喜欢这个想法,但找不到可接受的形式来接受它。”

Bjarne Stroustrup,C++ 的设计与演变 (p297)

以及后来的内容:

“多方法是 C++ 中有趣的假设之一。当时我可以足够好地设计和实现它们吗?[...] 可能还没有完成哪些其他工作来提供设计时间并实施多种方法?”

(p298f)

一般来说,每当您迫切想知道为什么某些特定的 C++ 功能被实现、未实现或以现在的方式实现,并且如果该功能早于标准化,您就需要阅读 D& ;E.

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.

小霸王臭丫头 2024-10-22 04:00:37

正如 Bjarne 多次指出的那样,当人们批评 C++ 时,通常会这样说:“C++ 太大了,太复杂了,有太多功能,而且太难学了——你应该真正努力让它变得更好。”哦,当你在努力的时候,我也有一个非常好的主意,你应该添加一个杀手级功能!”

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!"

阿楠 2024-10-22 04:00:37

仅仅因为它可以完成并不意味着它没有完成就是一个问题。对 C++ 的一种批评是“Stroustrup 吸收了任何人都听说过的一切,并试图将其包括在内”。

另外,正如 Raymond Chen 所说,“每个功能都以 -100 分开始。”也就是说,在你问为什么C++没有这些东西之前,你应该详细解释为什么它需要它们。否则,由于与之相关的成本,您的功能将处于负值区域。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文