MathLink 中的数据包链:数据包是否始终严格排序?
文档没有明确说明返回数据包的顺序 由从属内核通过 MathLink 实现。很自然地假设(当 发送带有头 EnterExpressionPacket
的输入表达式并在标准模式下工作):
1) 下一个 InputNamePacket
之前的最后一个数据包始终是 ReturnExpressionPacket
2) 可能始终只有一个 ReturnExpressionPacket
和一个 OutputNamePacket
代表一个 EnterExpressionPacket
3) ReturnExpressionPacket
始终是 OutputNamePacket
之后的下一个
4) MessagePacket
之后code> 下一个数据包始终是 TextPacket
该消息的所有内容
5) 标准模式下返回的数据包只有 7 种类型:InputNamePacket
、OutputNamePacket
、ReturnExpressionPacket
、DisplayPacket
、DisplayEndPacket
、 消息包
,文本包
。
以下哪些说法是正确的?
The Documentation does not state clear the order of packets returned
by slave kernel via MathLink
. It is natural to suppose that (when
sending an input expression with head EnterExpressionPacket
and working in standard mode):
1) the last packet before the next InputNamePacket
is alwaysReturnExpressionPacket
2) there may be always only one ReturnExpressionPacket
and oneOutputNamePacket
for one EnterExpressionPacket
3) ReturnExpressionPacket
is always the next after OutputNamePacket
4) after MessagePacket
the next packet is always TextPacket
with
all contents of that message
5) there are only 7 types of returned packets in the standard mode: InputNamePacket
, OutputNamePacket
, ReturnExpressionPacket
, DisplayPacket
, DisplayEndPacket
,MessagePacket
, TextPacket
.
Which of these statements are true?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,您编写的代码不应依赖于来自内核的数据包的顺序。在您收到新的 InputNamePacket 之前,评估应被视为“活动”。 OutputNamePacket 应该更新一些变量。 ReturnExpressionPacket 应使用该变量的当前输出名称。如果您收到未知数据包,只需忽略它并继续处理下一个数据包。
In general you should write your code to not rely on the order of packets coming from the kernel. The evaluation should be considered "active" until you receive a new InputNamePacket. OutputNamePacket should update some variable. ReturnExpressionPacket should use the current output name from that variable. If you receive an unknown packet simply ignore it and move on to the next packet.