envir.c
に周りのヌードリングのビットが、私は仕事にこれを取得することができます:
#include <Rcpp.h>
using namespace Rcpp ;
#define HASHSIZE(x) LENGTH(x)
#define HASHVALUE(x) TRUELENGTH(x)
// [[Rcpp::export]]
SEXP get_binding_fun(std::string name, Environment env){
SEXP symbol = Rf_install(name.c_str());
SEXP tab = HASHTAB(env) ;
SEXP c = PRINTNAME(symbol);
// finding the hash code for the symbol
int hashcode = HASHVALUE(c) % HASHSIZE(tab);
// get the value there from the hash table
SEXP res = CAR(VECTOR_ELT(tab, hashcode)) ;
return res ;
}
sourceCpp
に、.cpp
ファイルにこれを保存して、このRコードとそれを使用します。
> makeActiveBinding("x", function() runif(2), .GlobalEnv)
> get_binding_fun("x", .GlobalEnv)
# function()
# runif(2)
ロマンフランソワSUGこの動作を修正するために[2009年のR-develへのパッチ](https://stat.ethz.ch/pipermail/r-devel/2009-June/053899.html)を吟味しました([Cコードでの添付ファイルへのリンクを参照してください] ](https://stat.ethz.ch/pipermail/r-devel/attachments/20090629/16a8c41a/attachment.pl) – Andrie
@Andrieこのパッチはバインディング機能を提供していませんでした。これは実際にアクティブなバインディングであることだけを表示します –
@Andrie興味深いですが、IIUCでは、Romainのパッチが 'str(x)'のために行うように見えるのは、文字列 " \ n"を表示することです(あるいは 'cat()')。それもあなたが見ているものですか? –