我刚刚分析了一段由不太受欢迎的人工智能生成的代码:
dt = Open("$SAMPLE_DATA/Big Class.jmp");
kd = dt << KDTable("hello");
result = kd << K Nearest Rows(1, 3);<BR />print("finished");
日志显示:
Object 'Data Table' does not recognize the message 'K Nearest Rows'; perhaps you mean one of these: <
<<<<<<<<
finished
Sure: if a scriptable object doesn't understand a message, it shows such a warning message in the log.
And a Data Table doesn't understand the the message K nearest Rows().
But wait, why is kd a data table?!
This is easy to answer: In the previous line of code, the data table doesn't understand the command << KDTable("hello");
And therefore, instead of returning a KD table, it returns a reference to itself.
Unfortunately, here is NO warning message:
Object 'Data Table' does not recognize the message 'KD Table("hello")'
A JSL scripter will spot the error within seconds : KD Table("hello") , tztztz!
But you’d probably agree—it’s hard to find the error from the information JMP provides!
How to escape this issue? Is there a general rule or trick?
Can JMP / the JSL interpreter be improved to help AI and the users understand the errors?
Users with paranoia could add If (type(name Expr(returned object) == ...) after every message sent to a scriptable object. Hm ...
JMP 就是这样设计的。我也希望它能有所不同。造成这种情况的设计原理是:(1) 对象会忽略它们无法识别的消息;(2) 消息可以链式传递。早在很多版本之前,JMP 就添加了一个选项,允许某些对象报告无法识别的消息。这个选项是否有效取决于对象本身;我认为所有显示框都有一些通用的代码来处理这种情况。
链式消息,例如 tb<
按照这些规则,你示例中的第 2 行代码实现了它应该实现的功能。
我认为默默忽略未识别消息的做法可能源于对微软 Windows 消息处理(上个世纪)的研究;有大量消息会被默默忽略(例如鼠标在你上方移动,但你根本不打算响应鼠标)。在 JMP 中,可以这样使用:{ textBox, outlineBox } << setcolor("red") << close(1); 其中列表中任何能够识别 < 的框<<>
你的示例向数据表发送的两条消息之间的区别在于: kdtable()是一个全局的、类似平台的函数,而< < m>这是只有 kdtable 对象才能识别的消息。数据表本身喜欢接收类似平台启动的消息, dt< 例如,这里存在一个错误。我怀疑是 kdtable 没有报告“hello”参数的问题,导致数据表误以为启动了一个平台。也许是空平台(抱歉,实际上并不存在空平台)。
kdtable("hello")
/*:
Empty()
嗨
@Craige_Hales ,非常感谢您提供的详细背景信息——当然,我能理解
为什么JSL 当时是这样设计的(静默忽略未知消息 + 链式调用返回左侧对象)。
然而,我也希望 JSL 的开发者们能够意识到,这种模式与当今人工智能辅助的氛围编码方式已经变得有些“不兼容”:
LLM(层级管理)会随意创建消息、平台调用和参数,但目前的行为却常常让它们被默默忽略。这不仅会造成混乱,还会让调试变成一场噩梦——最终你只能找到症状,而无法找到根本原因。
或许,开发者可以提供一个 JSL 级别的开关,用于“AI 调试/聊天模式” :
故意为选定的对象类(例如显示对象、平台、一般可脚本化对象)启用嘈杂但极其有用的诊断信息。
其理念是,当最终结果出现异常时,启用此模式,JMP 会在问题最初出现偏差的地方立即发出警告,而不是悄无声息地失败,直到很久之后才发出警报。我已经将此功能添加到愿望清单中,供大家投票:
用于 AI 调试的“聊天模式()”。
再次感谢您提供的见解,并确认这方面确实有需要改进的地方。