在我的clojure程序中,我无法访问java类com.foo.Foo的包范围字段,尽管我在命名空间"com.foo"中(通过我的clojure程序顶部的"(ns com.foo)").但是,com.foo.Foo中的公共字段是可访问的.
为什么?
我是新手来提升精神,我有以下问题:
#include <string>
#include <vector>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#include <boost/spirit/include/phoenix_statement.hpp>
#include <boost/bind.hpp>
using namespace boost::spirit;
using namespace std;
struct MyGrammar
: qi::grammar<string::const_iterator, string(), ascii::space_type> {
MyGrammar();
void myFun(const string& s);
private:
qi::rule<string::const_iterator, string(), ascii::space_type> myRule;
};
using namespace boost::spirit;
using namespace std;
MyGrammar::MyGrammar() : MyGrammar::base_type(myRule) {
using qi::_1;
myRule = int_ [boost::bind(&MyGrammar::myFun, this, _1)]; // fails
myRule = int_ [_val = _1]; // fine
}
void MyGrammar::myFun(const string& s){
cout << "read: " << s << endl; …Run Code Online (Sandbox Code Playgroud) 我读到 data.table 理解点“。” 作为“列表”的别名。但:
> dt <- data.table(x = c(11, 22), y = c("f", "b"))
> dt
x y
1: 11 f
2: 22 b
> dt[,.(y)]
Error in eval(expr, envir, enclos) : could not find function "."
>
Run Code Online (Sandbox Code Playgroud)
这是为什么?
在 R 中,我需要作为参数传递给嵌套函数的函数的名称。
> fun1 <- function(f) deparse(substitute(f))
> fun2 <- function(f) fun1(f)
> fun1(mean)
[1] "mean"
> fun2(mean)
[1] "f"
>
Run Code Online (Sandbox Code Playgroud)
如何获得一个函数的名称,而与它作为参数传递给嵌套函数的次数无关?