据我所知,该module!类型为受保护的命名空间提供了比object!该'use函数更好的结构.如何在模块中绑定单词 - 我注意到与未绑定单词相关的一些错误:
REBOL [Type: 'module] set 'foo "Bar"
Run Code Online (Sandbox Code Playgroud)
另外,Rebol如何区分module('foo)的本地字和系统函数('set)的字?
稍后更新,不久之后:
我看到有一个改变绑定方法的开关:
REBOL [Type: 'module Options: [isolate]] set 'foo "Bar"
Run Code Online (Sandbox Code Playgroud)
这有什么不同的做法?默认情况下使用此方法有什么问题?
给定一个字符串string,在其中计算行的最快/最有效的方法是什么?将接受任何风格的Rebol的最佳答案.我一直在假设parse [some [thru]]组合是遍历字符串的最快方式,但后来我不确定,因此转向SO:
count-lines: func [string [string!] /local count][
parse/all string [
(count: 1) some [thru newline (count: count + 1)]
]
count
]
Run Code Online (Sandbox Code Playgroud)
要么:
count-lines: func [string [string!] /local count][
count: 0
until [
count: count + 1
not string: find/tail string newline
]
count
]
Run Code Online (Sandbox Code Playgroud)
柜台怎么样?重复效率如何?
count-lines: func [string [string!]][
repeat count length? string [
unless string: find/tail string newline [
break/return count
]
]
]
Run Code Online (Sandbox Code Playgroud)
更新:行计数采用文本编辑器原则:

空文档的行数仍为1.所以:
>> count-lines ""
== 1 …Run Code Online (Sandbox Code Playgroud) 想象一下以下REBOL代码:
foo: context [bar: 3]
我现在有一个上下文foo中'bar定义.如何在此上下文中动态注入新单词?可能吗?
我试过了:
set/any in foo 'baz 3
但这不起作用,因为表达式in foo 'baz失败,因为上下文中没有'baz定义单词foo.
我应该补充一点,我知道有一种方法可以做到这一点:
foo-prototype: [bar: 3] foo: context foo-prototype foo: context head append foo-prototype [baz: 3]
但是,如果您无法访问foo原型块呢?
我为Rebol 2编写了一个JSON编码器/解码器.我正在为Rebol 3重写它,并希望在Rebol 3中将它作为编解码器提供:
load %data.json
save %data.json object
decode 'json to-binary {["some","json"]}
Run Code Online (Sandbox Code Playgroud)
我该怎么办呢?
在询问时,关于这个主题的文件很少.
我正在尝试使用字符串中的Rebol 2/3解析货币值,货币值的格式如下:
10,50€或10,50€
我通过所有PARSE文档找到了这段代码,我发现它可以用Red实现,但不能用于Rebol 2或3.
digit: charset [#"0" - #"9"]
digits: [some digit]
euro: [digits "," digits [any " "] "€"]
parse "hello 22 44,55€ 66,44 € 33 world" [
some [
to euro
copy yank thru euro
(print yank)
]
]
Run Code Online (Sandbox Code Playgroud)
在玩了很长一段时间之后,我得出的结论是TO/THRU由于某种原因不适用于数字(它似乎与字符一起使用),但是我无法弄清楚如何解析它TO/THRU因为字符串具有需要跳过的任意内容.
(来自tryrebol)
44,55€
66,44 €
Run Code Online (Sandbox Code Playgroud)
*** ERROR
** Script error: PARSE - invalid rule or usage of rule: [some digit]
** Where: parse try do either either either -apply-
** Near: parse "hello 22 …Run Code Online (Sandbox Code Playgroud) 我有一个如下所示的mysql架构:
data: {
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(10) DEFAULT '' COMMENT 'the name',
`content` text COMMENT 'something',
}
Run Code Online (Sandbox Code Playgroud)
现在我想从中提取一些信息:提交的名称,类型和评论(如果有的话).见下文:
["id" "int" "" "name" "varchar" "the name" "content" "text" "something" ]
Run Code Online (Sandbox Code Playgroud)
我的代码是:
parse data [
any [
thru {`} copy field to {`} {`}
thru some space copy field-type to [ {(} | space]
(comm: "")
opt [ thru {COMMENT} thru some space thru {'} copy comm to {'}]
(repend temp field repend temp field-type either comm [ …Run Code Online (Sandbox Code Playgroud) 我最近询问了在Rebol中计算换行的最快/最有效的方法 - 我现在需要确定在特定情况下哪种方法最好.
一些示例场景:短文本,较少的换行符; 短文,许多新线; 中/长文本,许多换行符(代码); 中/长文本,较少的换行符(文章).
我有一些不确定因素:如果我一个接一个地运行,第二个测试会被第一个测试污染吗?对于不同的场景(优化)需要不同的功能而不是一个功能适合所有(便利)需要多少差异?我需要BOTH Rebol 2.7.8和Rebol 3的基准测试.
以下是我想要测试的特定功能集,尽管还有更多通用答案:
reduce [
"@rebolek"
func [text [string!] /local i][
parse text [(i: 1) any [thru newline (++ i)]] i
]
"@darius"
func [text [string!] /local tmp][
tmp: sort join text "^/"
1 + subtract index? find/last tmp "^/" index? find tmp "^/"
]
"@endo64"
func [text [string!]][
(length? text) - (length? remove-each v text [v = #"^/"])
]
"@BrianH"
function [text [string!]] [
i: …Run Code Online (Sandbox Code Playgroud) 我在启用 FFI 扩展的情况下构建此项目时遇到问题。为了隔离问题,我正在尝试编译此示例(包含在下面的完整内容中)。
我使用的是 OS X 10.13.2、Xcode 9.2,并安装了命令行工具(确认/usr/include/ffi/ffi.h存在)。我修改了示例,因此包含行读取include <ffi/ffi.h>.
在没有选项的情况下调用编译器,我得到以下信息:
$ gcc closure.test.c
closure.test.c:23:13: warning: implicit declaration of function 'ffi_closure_alloc' is invalid in C99 [-Wimplicit-function-declaration]
closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
^
closure.test.c:23:11: warning: incompatible integer to pointer conversion assigning to 'ffi_closure *' (aka 'struct ffi_closure *') from
'int' [-Wint-conversion]
closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
closure.test.c:35:15: warning: implicit declaration of function 'ffi_prep_closure_loc' is invalid in C99 [-Wimplicit-function-declaration]
if (ffi_prep_closure_loc(closure, &cif, puts_binding,
^
closure.test.c:45:3: …Run Code Online (Sandbox Code Playgroud) 我正在使用Cheyenne v0.9并希望提供静态HTML文件text/html,但我不希望URL包含.html扩展名.有没有办法在不使用CGI或其他动态处理器的情况下执行此操作?
例如:
/path/to/example.org/web-root/about.html
Run Code Online (Sandbox Code Playgroud)
使用以下方式联系:
http://example.org/about
Run Code Online (Sandbox Code Playgroud)
Apache等效的'ReWrite'类似于:
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]
Run Code Online (Sandbox Code Playgroud) 这可以在Rebol 2.7.8中使用/ View二进制文件使用本机方案,使用/ Core使用callshell命令.但是在发布时我没有看到Rebol 3的本地HTTPS方案,也没有看到call具有多功能性的命令,例如,使用cURL依赖项创建方案.本机方案更可取,因为这可以跨平台工作.