为什么信号不简单地称为事件?

发布于 2024-07-14 12:51:12 字数 88 浏览 8 评论 0原文

据我所知,在 Python 和 Django 中,信号只是委托事件。 它们在功能上与 C#、Java、ActionScript 等中的典型事件概念有什么区别吗?

From what I can tell, in Python and and Django, signals are simply delegated events. Is there anything that functionally differentiates them from the typical notion of events in C#, Java, ActionScript, etc?

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

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

发布评论

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

评论(4

慵挽 2024-07-21 12:51:12

事实上,“信号”的存在时间比事件的存在时间还要长。 在最早的使用中,信号是进程获取事件发生通知的异步方式。 由于 Unix 比 Django 更古老(而且 Django 的很多工作都来自 pydispatcher,原始的东西就是在那里完成的),所以这个名字就一直沿用下来了。

您可能会说,事件实际上是信号!

Actually, "signals" have been around longer than events have. In the earliest usage, a signal was an asynchronous way for processes to get notified that events had occurred. Since Unix is much older than Django (and since a lot of the Django work came from pydispatcher, where the original stuff was done), the name has stuck.

Events are really signals, you might say!

梦言归人 2024-07-21 12:51:12

信号通常与操作系统设施相关联,而事件通常是应用程序定义的。 在某些技术堆栈中,操作系统级别的内容可能隐藏得足够好,以至于 API 中没有差异,但在其他技术堆栈中可能不会。

Signals typically have an association with an operating system facility and events are typically application-defined. In some technology stacks, the OS-level stuff may be hidden well enough that there isn't a difference in the API, but in others perhaps not.

白云悠悠 2024-07-21 12:51:12

Afaik Qt 拥有第一个信号/槽实现。 Qt 文档解释了这个比喻:“当特定事件发生时会发出信号”。 这种区别是如此微妙,以致于术语已经模糊了。

Afaik Qt had the first signal/slot implementation. Qt's docs explain the metaphor: "A signal is emitted when a particular event occurs". The distinction is so subtle that the nomenclature has been blurred.

梦一生花开无言 2024-07-21 12:51:12

您不妨问“为什么事件不简单地称为信号?”。 术语上存在差异。

You might as well ask "Why aren't events simply called signals?". Differences in terminology happen.

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