我说"实时代码"因为我的意思不是来自文本源文件或源字符串,而是来自partialFunctions/lambdas.(我知道Ruby1.8的parseTree和C#linq可以做到)
考虑一个partialFunction f:
val f = (i: Int, j: Int) => (i + j) * 2
Run Code Online (Sandbox Code Playgroud)
我希望有一些工具像这样:
getBodyAstFrom(f) //=> (Infix('*'), (Infix('+'), Id('i'), Id('j')), Val('2'))
Run Code Online (Sandbox Code Playgroud)
我不关心语义事物(上下文解析和implicits太复杂,对我来说是不必要的),我只需要实时代码的语法树,是否可能?
检查其他人的代码可能存在问题,但我自己的代码呢?以下事情可能吗?
val f = AstFunction(i: Int, j: Int){(i + j) * 2}
f(5, 6) //=> 22
f.ast //=> (Infix('*'), (Infix('+'), Id('i'), Id('j')), Val('2'))
Run Code Online (Sandbox Code Playgroud)
它似乎需要一些黑客入侵编译器,嗯......
scala中有一些"全局"函数,例如:
print
println
classOf
format
Run Code Online (Sandbox Code Playgroud)
前两个实际上是Console的单例方法,最后一个来自java.lang.String.format.
我相信还有更多,可能有人列出所有这些,或指出我可以在哪里找到相应的API文档?
我找不到任何描述独角兽数据库连接池效应的文档.
Unicorn分叉了几个工人流程.我配置了prefork,关键是不要在worker之间共享数据库连接,所以我在fork之后重置db连接.
我的rails应用程序每个服务器有8个worker,而database.yml中的pool大小是5,然后我看到了45个与mysql的连接.
每个worker都是单线程的,一次处理1个请求.SQL查询应该是阻塞的.似乎其他4个连接都没用?我可以将池大小设置为1以获得更好的性能吗?
如何用mingw gcc链接msvcr90.dll?我试过-lmsvcr90,这是最小的例子:
#include <stdio.h>
int main(int argc, const char *argv[]) {
printf("%s\n", "hello");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我的操作系统是win7,mingw gcc 4.5.0
$ gcc -v
...
gcc version 4.5.0 (GCC)
$ gcc hello.c -lmsvcr90
$ a
Run Code Online (Sandbox Code Playgroud)
然后我收到了这个错误:
R6034
An application has made an attempt to load the C runtime library incorrectly. Please contact the application's support team for more information.
我错过了哪一部分?
EDIT1:
@ user440813似乎我的mingw与你的明显不同.
$ gcc h.c -nostdlib -lmsvcr70 -lgcc -o h.exe
d:/mingw/bin/../lib/gcc/mingw32/4.5.0/libgcc.a(__main.o):(.text+0x5a): undefined reference to `atexit'
d:/mingw/bin/../lib/gcc/mingw32/4.5.0/libgcc.a(__main.o):(.text+0xc2): undefined reference to `atexit'
collect2: …
Run Code Online (Sandbox Code Playgroud)