<div dir="ltr">Hi,<div>I was wondering why I can serialize a call such as in</div><div><br></div><div>serialize(call("ripley"), NULL) </div><div><div>[1] 58 0a 00 00 00 02 00 03 00 02 00 02 03 00 00 00 00 06 00 00 00 01 00 04 00 09 00 00 00 06 72 69 70 6c 65 79 00 00 00 fe</div>


</div><div><br></div><div>but if I try from C++ the call gets evaluated</div><div><br></div><div> library("Rcpp")<br></div><div><div><br></div><div> rcpp.serialize = cppFunction(code="RObject my_serialize(RObject x){Function r_serialize(\"serialize\"); return r_serialize(x, R_NilValue);}")<br>


</div><div><br></div><div> rcpp.serialize(10)</div><div> [1] 58 0a 00 00 00 02 00 03 00 02 00 02 03 00 00 00 00 0e 00 00 00 01 40 24 00 00 00 00 00 00</div><div># easy things work</div><div><br></div><div> rcpp.serialize(call("ripley"))</div>


<div>Error: could not find function "ripley"</div><div># wants to evaluate it</div><div><br></div><div> unserialize(rcpp.serialize(call("sqrt", 2)))<br></div><div>[1] 1.414214</div><div># How is one to serialize the call itself</div>


<div><br></div><div> rcpp.serialize(list(call("ripley")))</div><div> [1] 58 0a 00 00 00 02 00 03 00 02 00 02 03 00 00 00 00 13 00 00 00 01 00 00 00 06 00 00 00 01 00 04 00 09 00 00 00 06 72 69 70 6c 65 79 00 00 00 fe</div>


</div><div>#wrapping in a list is enough to stop evaluation</div><div><br></div><div><div> eval(call("ripley"))</div><div>Error in eval(expr, envir, enclos) : could not find function "ripley"</div><div>


 eval(list(call("ripley")))</div><div>[[1]]</div><div>ripley()</div></div><div><br></div><div>#OK that's consistent</div><div><br></div><div><br></div><div>Could anyone enlighten me on the evaluation mechanism? Not saying it's broken, but certainly my expectations were off. Thanks</div>


<div><br></div><div><br></div><div>Antonio</div></div>