我正在尝试Parenscript。在尝试使用正则表达式功能时,得到了意外的输出。例如,reference manual显示:
(regex "foobar")
/foobar/;
(regex "/foobar/i")
/foobar/i;
但是在我的repl中,我得到一个错误,该函数(parenscript:regex ..)未定义。
The function parenscript:regex is undefined.
[Condition of type undefined-function]
Restarts:
0: [continue] Retry using regex.
1: [use-value] Use specified function
2: [retry] Retry SLIME REPL evaluation request.
3: [*abort] Return to SLIME's top level.
4: [abort] abort thread (#<thread "repl-thread" running {1002319B63}>)
Backtrace:
0: (sb-impl::retry-%coerce-name-to-fun regex nil)
1: (sb-int:simple-eval-in-lexenv (regex "foobar") #<NULL-LEXENV>)
2: (eval (regex "foobar"))
--more--
我尝试将名称空间更改为cl-user,ps等,但没有任何效果。 OTOH,仅用于检查,我尝试使用sin,random等函数,并且该方法有效。我的意思是,在repl中键入(sin 0.1)会产生预期的输出。
任何帮助都会有很大帮助。
答案 0 :(得分:2)
在SBCL中,读取-评估-打印循环:
CL-USER> (in-package "PS")
#<PACKAGE "PARENSCRIPT">
PS> (ps (regex "foobar"))
"/foobar/;"
PS> (in-package "CL-USER")
#<package "COMMON-LISP-USER">
cl-user> (ps:ps (ps:regex "foobar"))
"/foobar/;"
PS:PS
是作为宏运算符的Parenscript编译器。