回复:改進 JMP 編譯器上下文感知 - 狀態更改為:已確認感謝您的意見。 我們希望讓用戶知道他們何時可能覆蓋核心 JMP 函數。 我可以想像這對於更專業的用戶來說可能會很煩人。 我們將與我們的開發團隊分享這一點,看看我們是否可以提供一種方法來抑制這樣的警告消息。 挑戰在於如何確定哪些警告消息應該或可以被抑制。
我想如果您一遍又一遍地定義這樣的函數,可能會導致日誌被填滿。 您在腳本和相關日誌文件中多久會看到這種情況發生? 此外,以不同方式定義函數會阻止日誌中出現此類消息,例如
"test namespace":customprint=Function({}, "will this print?");
回复:改進 JMP 編譯器上下文感知 - 狀態更改為:正在調查回复:改進 JMP 編譯器上下文感知感謝您的回复 - 這並不是一個太大的麻煩 - 這是當 AddinLoad 運行並且我的類初始化時 - 我已將實例生成器切換為使用下面的方法,以避免將這些消息放入日誌中新實例。
因此,如果這件事對你來說很容易完成,那就太好了,但這絕不是一個高優先級的事情。
new namespace( "test",
{
print = Function( {},
show( "test" )
)
}
);
"test":print;回复:改進 JMP 編譯器上下文感知我相信這是一個更好的解決方法:
x=New Namespace( "This is a NAMESPACE -- it is different than BUILTIN!!!!!!!!!!!!!!!" );
x["print"] = Function( {},
Print( "hello 1" )
);
"This is a NAMESPACE -- it is different than BUILTIN!!!!!!!!!!!!!!!":print(); // hello 1
// or
y=namespace("This is a NAMESPACE -- it is different than BUILTIN!!!!!!!!!!!!!!!");
y["print"] = Function( {},
Print( "hello 2" )
);
"This is a NAMESPACE -- it is different than BUILTIN!!!!!!!!!!!!!!!":print(); // hello 2
// or
namespace("This is a NAMESPACE -- it is different than BUILTIN!!!!!!!!!!!!!!!")["print"] = Function( {},
Print( "hello 3" )
);
"This is a NAMESPACE -- it is different than BUILTIN!!!!!!!!!!!!!!!":print(); // hello 3
x:print(); // hello 3
y:print(); // hello 3
// the above is to work around the log message from variations on this:
x:print = Function( {},
Print( "hello 4" )
);
/*
The user-defined function "Print" conflicts with the JMP function "Print".
Use a scoped reference (for example, Global:Print or Here:Print) to call
your user-defined function. Other uses of "Print" in your script source
will continue to call the JMP function.
*/
// which actually works...
"This is a NAMESPACE -- it is different than BUILTIN!!!!!!!!!!!!!!!":print(); // hello 4
// logcapture() is a less pretty way to make the message go away.
// The associative array style assignment prevents JMP from looking up the "print"
// name in the usual way.
// shownamespaces(); // there is only one; x and y are alternate ways to use it
我不喜歡在 NewNameSpace 參數列表中添加賦值語句(簡單常量除外),因為它們保留為仍需要計算的表達式。 因此,在您的示例中, print 是一個包含函數定義的表達式,並且在實際函數運行之前,每次使用時都會將其重新計算為實際函數。 它做實現你的目標,因為它永遠不會創建一個名為 print 的變量來保存函數......只是一個計算結果為函數的表達式。
z = New Namespace(
"z",
f = If( Is Missing( Beep() ), // this is evaluated later, on each access
1,
2
)
);
z:f; // beep!
我同意,目前的消息不應該發生在這種情況下;我希望它能得到修復。
提高 JMP 編譯器上下文感知能力是什麼激發了這個願望清單請求?發送到日誌的訊息可能很慢而且也會讓用戶感到困惑
您希望看到什麼改進?不要用無用的訊息淹沒日誌
為什麼這個想法很重要?確實,這更麻煩。
考慮以下 JSL —— 我將一個函數附加到自訂命名空間中的名稱「print」。
New Namespace( "This is a NAMESPACE -- it is different than BUILTIN!!!!!!!!!!!!!!!" );
"This is a NAMESPACE -- it is different than BUILTIN!!!!!!!!!!!!!!!":print = Function( {},
Print( "Why does JMP think I am trying to overwrite a Builtin???" )
)

為什麼我會收到此警告?我並不是想覆蓋內置的。我知道我將名稱放入命名空間中,這就是我訪問該名稱所保存的值的方式。
當名稱位於命名空間內時,JMP 編譯器是否可以知道並且不將這些訊息傳送到日誌?我使用命名空間來建立自訂類,因此每當建立新實例時,它都會向日誌中發送這些多餘的訊息。
自動化和腳本編寫回覆:改進 JMP 編譯器上下文感知 - 狀態更改為:已確認