为什么信号不简单地称为事件?
据我所知,在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
事实上,“信号”的存在时间比事件的存在时间还要长。 在最早的使用中,信号是进程获取事件发生通知的异步方式。 由于 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!
信号通常与操作系统设施相关联,而事件通常是应用程序定义的。 在某些技术堆栈中,操作系统级别的内容可能隐藏得足够好,以至于 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.
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.
您不妨问“为什么事件不简单地称为信号?”。 术语上存在差异。
You might as well ask "Why aren't events simply called signals?". Differences in terminology happen.