回复:改进 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 编译器上下文感知 - 状态更改为:已确认