I just analyzed a code created by a less favorite AI:
dt = Open("$SAMPLE_DATA/Big Class.jmp");
kd = dt << KDTable("hello");
result = kd << K Nearest Rows(1, 3);<BR />print("finished");
The log said:
Object 'Data Table' does not recognize the message 'K Nearest Rows'; perhaps you mean one of these: <<Insert Rows <<Delete Rows <<Select Rows <<Select All Rows <<Get Labeled Rows <<Get Hidden Rows <<Get Excluded Rows <<Clear Cell Colors <<Make Indicator Columns... <<Get as Matrix <<Get As Report <<Get Row States <<Get Rows Where <<Get Selected Rows <<Clear Edit Lock <<Make SAS DATA Step <<Make SAS DATA Step Window <<New Data View <<New Data Box <<Markers <<Go to Row… <<Invert Row Selection <<Select Duplicate Rows <<Clear Row States <<Clear Selected Row States <<Add Rows… <<Get Rows <<Move Rows… <<Clear Sel
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 ...