奇怪的 rebol bug:错误需要一个值
当执行
do-file: func[file][
if error? error: try [
if (find [%.r %.cgi] (suffix? file)) [
do file
]
][
disarm error
print ["error executing " file]
input
]
]
foreach-file: func [
"Perform function on each file in selected directory recursively"
dir [file! url!] "Directory to look in"
act [function!] "Function to perform (filename is unput to function)"
/directory "Perform function also on directories"
/local f files
][
if not equal? last dir #"/" [
dir: to-rebol-file join dir #"/"
]
files: attempt [read dir]
either none? files [return][
foreach file files [
f: join dir file
either dir? f [
either directory [
act f
foreach-file/directory f :act
][
foreach-file f :act
]
][act f]
]
]
]
feach-file %test/ :do-file
where %test 将包含一个仅包含 rebo 标头的文件时:
rebol []
程序因错误而停止,而不是解除错误!
如果文件包含类似内容,它不会给出错误
rebol []
test: context []
,但如果它包含
rebol []
print ""
Why ,它会再次失败?
When executing
do-file: func[file][
if error? error: try [
if (find [%.r %.cgi] (suffix? file)) [
do file
]
][
disarm error
print ["error executing " file]
input
]
]
foreach-file: func [
"Perform function on each file in selected directory recursively"
dir [file! url!] "Directory to look in"
act [function!] "Function to perform (filename is unput to function)"
/directory "Perform function also on directories"
/local f files
][
if not equal? last dir #"/" [
dir: to-rebol-file join dir #"/"
]
files: attempt [read dir]
either none? files [return][
foreach file files [
f: join dir file
either dir? f [
either directory [
act f
foreach-file/directory f :act
][
foreach-file f :act
]
][act f]
]
]
]
feach-file %test/ :do-file
where %test would contain a file with just rebo header:
rebol []
The program stops with an error instead of disarming the error !
It doesn't give an error if the file contains something like
rebol []
test: context []
but it would fail again if it contains
rebol []
print ""
Why ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
必须为设置的单词提供一个值,如下控制台会话所示:
解决方案是使用 set/any 而不是 set 词。
描述:
将单词、单词块或对象设置为指定值。
SET 是一个原生值。
论据:
word -- 要设置的一个或多个单词(类型:任意单词块对象)
value -- 值或值块(类型:任何类型)
改进:
/any——允许将单词设置为任何值。
/pad -- 对于对象,如果块太短,则剩余字设置为 NONE。
你可以使用类似的东西:
顺便说一句,您可以通过 Rebol 邮件列表存档找到许多问题的答案,网址为 http://www.rebol.org/ml-index.r。
A set word must be supplied with a value as illustrated by this console session:
The solution is to use set/any instead of a set word.
DESCRIPTION:
Sets a word, block of words, or object to specified value(s).
SET is a native value.
ARGUMENTS:
word -- Word or words to set (Type: any-word block object)
value -- Value or block of values (Type: any-type)
REFINEMENTS:
/any -- Allows setting words to any value.
/pad -- For objects, if block is too short, remaining words are set to NONE.
You can use something like:
By the way, you can find the answers to many of your questions through the Rebol Mailing List Archive at http://www.rebol.org/ml-index.r.
那些括号是不必要的。
这是另一种风格
Those parentheses were unnecessary.
Here's an alternate style
成功创建文件时没有返回有效值。
set-word 需要一个值,而 set/any 可以接受任何值。
There is no a valid value returned when success do a file.
while set-word need a value, set/any can accept any value.