Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Debugging 在以变量作为参数的rebol函数中,如何检索原始变量_Debugging_Rebol - Fatal编程技术网

Debugging 在以变量作为参数的rebol函数中,如何检索原始变量

Debugging 在以变量作为参数的rebol函数中,如何检索原始变量,debugging,rebol,Debugging,Rebol,我正在调试一个脚本,它的行为与我所希望的不一样 我正在编写一个小的调试实用程序函数,它将打印“word”,后跟它的值。 我写道: debug: func [x] [print rejoin ['x " => " x] wait 0.5 ] 在我的代码中,我想简单地这样称呼它: phrase: "beer is good" mots: parse phrase " " debug phrase foreach mot mots [ debug mot ;do som

我正在调试一个脚本,它的行为与我所希望的不一样

我正在编写一个小的调试实用程序函数,它将打印“word”,后跟它的值。 我写道:

debug: func [x] [print rejoin ['x " => " x] wait 0.5 ]
在我的代码中,我想简单地这样称呼它:

phrase: "beer is good"
mots: parse phrase " "
debug phrase
    foreach mot mots [
    debug mot
    ;do something...
    ]
我梦想它能在控制台上输出如下内容:

phrase => "beer is good"
mot => "beer"
mot => "is"
mot => "good"

但是我找不到一种方法来检索变量的原始名称,也就是说,它的名称超出了函数的范围。

我搜索得不够

?? variable
做我需要的事

>> ? ??
USAGE:
    ?? 'name 

DESCRIPTION:
     Prints a variable name followed by its molded value. (for debugging)
     ?? is a function value.

ARGUMENTS:
     name -- (Type: any)

如果查看“调试函数”并将其与“?”的源代码进行比较,您将看到需要采取哪些不同的操作:

??: func [
    {Prints a variable name followed by its molded value. (for debugging)}
    'name
][
    print either word? :name [head insert tail form name reduce [": " mold name: get name]] [mold :name]
    :name
]

关于获取lit word参数的主题,将参数作为lit word和作为get word传递有细微的区别: