search for: r_nilvalue

Displaying 20 results from an estimated 274 matches for "r_nilvalue".

2010 Aug 21
1
Speed improvement to evalList
...' is the number of arguments already evaluated and hence not passed to evalArgs and hence to here. */ SEXP attribute_hidden evalList(SEXP el, SEXP rho, SEXP call, int n) { SEXP head, tail, ev, h; int mode; /* mode==0 is 0 args, mode==1 is 1 arg, mode==2 is >1 arg */ head = R_NilValue; mode = 0; while (el != R_NilValue) { n++; if (CAR(el) == R_DotsSymbol) { /* If we have a ... symbol, we look to see what it is bound to. * If its binding is Null (i.e. zero length) * we just ignore it and return the cdr with all its expressions evaluated; * if...
2019 Dec 15
4
source definition for R_NilValue/return from TYPEOF(R_NilValue)
Hello, for reasons I want to know the return value of TYPEOF(R_NilValue), I expect it to be NILSXP, but I can't find this documented anywhere. Ideally, I'd like to see the source definition of R_NilValue, but after fair bit of searching I cannot find an obviously location for this. Would someone please point me in the right direction? thanks -- CRICOS provide...
2009 Nov 18
1
R_NilValue and segfault.
Hello. I've been trying to wrap up the R_NilValue into OCaml-R. I nevertheless get a segfault. As I gathered, R_NilValue is declared in Rinternals.h: > /* Special Values */ > LibExtern SEXP R_NilValue; /* The nil object */ > LibExtern SEXP R_UnboundValue; /* Unbound marker */ > LibExtern SEXP R_MissingArg; /* Mi...
2014 Feb 26
1
help with gotoExitingHandler(R_NilValue, call, entry); . Implementation of error handling internally
...from R_ReturnedValue. This works well in the ? not simple error ? case, i.e. if I call stop( simpleError(...) ), but with simple errors, i.e. calls to Rf_error internally or bare calls to stop( "vvzvz" ) I can?t access the error. And this boils down to this call: gotoExitingHandler(R_NilValue, call, entry); inside vsignalError : static void vsignalError(SEXP call, const char *format, va_list ap) { char localbuf[BUFSIZE]; SEXP list, oldstack; oldstack = R_HandlerStack; Rvsnprintf(localbuf, BUFSIZE - 1, format, ap); while ((list = findSimpleErrorHandler()) != R_Nil...
2019 Dec 16
0
source definition for R_NilValue/return from TYPEOF(R_NilValue)
On Sun, 15 Dec 2019 10:47:11 +0000 Dan Kortschak <dan.kortschak at adelaide.edu.au> wrote: > I'd like to see the source definition of R_NilValue, but after > fair bit of searching I cannot find an obviously location for this. > > Would someone please point me in the right direction? As far as I understand, the assignment to R_NilValue happens in src/main/memory.c: https://github.com/wch/r-source/blob/776929704cb4f9398f52805f48f2...
2010 Sep 08
0
Correction to vec-subset speed patch
...or some future use, then removing it might be a mistake. -------------- next part -------------- Index: src/main/subset.c =================================================================== --- src/main/subset.c (revision 52822) +++ src/main/subset.c (working copy) @@ -59,73 +59,77 @@ if (x == R_NilValue) return x; - for (i = 0; i < n; i++) { - ii = INTEGER(indx)[i]; - if (ii != NA_INTEGER) - ii--; - switch (mode) { - case LGLSXP: - if (0 <= ii && ii < nx && ii != NA_LOGICAL) - LOGICAL(result)[i] = LOGICAL(x)[ii]; - else - LOGICAL(result)[i] = NA_INTEGE...
2002 Aug 23
1
R_NilValue blows up on Windows
...ccess of real-time tick data. Everything works great, compiles on Win2000, R 1.3.1 and R 1.5.1 with Borland's free C++ 5.5, and runs into .dll. All functions work great except when there's no data from the database I do if (nrows <= 0) { Rprintf("No rows..."); return R_NilValue; } And there lies the blow up of Rterm!!! Apparently R_NilValue can be assigned to any SEXP object internally, but when it's returned, Rterm doesn't know what to do with it. I tried another bypass: SEXP NIL; if (nrows <= 0) { Rprintf("No rows..."); return NIL;...
2020 Sep 07
0
some questions about R internal SEXP types
Thanks, Gabriel. On Mon, 2020-09-07 at 14:38 -0700, Gabriel Becker wrote: > I cannot speak to initial intent, perhaps others can. I can say that > there is at least one place where the difference between R_NilValue > and NULL is very important as of right now. The current design of the > ALTREP framework contract expects ALTREP methods that return a SEXP > to return C NULL when they fail (or decline) to do the requested > computation and the non-altclass-specific machinery should be run as > a...
2005 Aug 17
2
About R variable references
...fully make clear what I am trying to achieve. The code is provided for illustration purposes only and I did not try to compile it. Best regards, Markku Mielityinen # C CODE ##################################################################### SEXP myrho = R_GlobalEnv; SEXP myvariable = R_NilValue; SEXP myfunction = R_NilValue; SEXP myinit(SEXP var, SEXP func) { myvariable = var; myfunction = func; return R_NilValue; } SEXP myexec(/* probably has some parameters that are omitted in this example */) { int state; SEXP thecall; /* do some work, then set the state and call a callback f...
2007 Jul 25
6
Using R_MakeExternalPtr
...g a package, so I hope you can bear with me. The following is how I create the class and use R_MakeExternalPtr(). This occurs in a function called "soamInit": Session* sesPtr = conPtr->createSession(attributes); void* temp = session; SEXP out = R_MakeExternalPtr(temp, R_NilValue, R_NilValue); return out; The following is how I try to retrieve the class object in a different C++ function called "soamSubmit", where sesCon is the externalPtr : void* temp = R_ExternalPtrAddr(sesCon); Session* sesPtr = reinterpret_cast<Session*>(temp); The error...
2019 Sep 15
2
REprintf could be caught by tryCatch(message)
...ction(expr) { tryCatch(expr, message=function(m) cat("caught message\n"), warning=function(w) cat("caught warning\n"), error=function(e) cat("caught error\n") ) } library(inline) Cstop = cfunction(c(), 'error("%s\\n","a"); return R_NilValue;') Cwarning = cfunction(c(), 'warning("%s\\n","a"); return R_NilValue;') Cmessage = cfunction(c(), 'REprintf("%s\\n","a"); return R_NilValue;') catch(stop("a")) #caught error catch(warning("a")) #caught warning catch(m...
2023 Apr 14
0
sum(), min(), max(), prod() vs. named arguments in ...
...ts to sum()? If not, it could be relatively safe to make it a warning to pass named arguments to sum() that are not na.rm and later transition it to an error: --- src/main/summary.c (revision 84252) +++ src/main/summary.c (working copy) @@ -419,6 +419,8 @@ na_value = CAR(a); if(prev == R_NilValue) args = CDR(a); else SETCDR(prev, CDR(a)); + } else if (TAG(a) && TAG(a) != R_NilValue) { + warning("Named argument \"%s\" here is probably a mistake", CHAR(PRINTNAME(TAG(a)))); } prev = a; } (Can TAG(a) ever be NULL or anything other than R_NilValue...
2007 Feb 20
2
Problem with types on 64-bit
...with 64-bit machine ( I am using version R-2.4.1 ). The problem occurs when I am trying to detect a NULL STRSXP type. ( Perhaps I am doing this detection in the wrong way? ) On 32-bit the following works, and correctly identifies if I am passing NULL or a valid string object: if ( v_dta_start != R_NilValue && STRING_ELT( v_dta_start, 0 ) != R_NilValue ) { dta.start = CHAR( STRING_ELT( v_dta_start, 0 ) ); } Yet on a 64-bit machine I get the following errors: (1) when I pass NULL it goes into the if clause and then when it tries to set dta.start it displays: CHAR() can only be applied to...
2005 Apr 18
3
A 'true' R-wrapper for C++ classes
...C-wrapper. Here is a rough example to demonstrate the above: --------------------- C++ class: class foo { public: foo(); ~foo(); fun(); } --------------------- C-wrapper: extern "C" SEXP R_foo_init() { foo* obj = new foo(); SEXP res; PROTECT(res = R_MakeExternalPtr(obj, R_NilValue, R_NilValue)); UNPROTECT(1); return res; } extern "C" SEXP R_foo_fun(SEXP ptr) { foo *ptr = Hello I am trying to wrap some C++ classes into R. (1) Comparing the OOP and methods packages, I have came to this conclusion that OOP works much better for this wrapper -- please correc...
2010 Sep 09
0
calling Rf_initEmbeddedR error
...blem of Rf_initEmbeddedR function. I've tried with: try { int Argc1 = 1; char *Argv1[] = {"Rtest_1"}; int Argc2 = 1; char *Argv2[] = {"Rtest_2"}; // Init R(first) Rf_initEmbeddedR(Argc1, Argv1); // R package load SEXP e = R_NilValue; SEXP r = R_NilValue; PROTECT(e = lang2(install("source"), mkString("hreg.r"))); r = R_tryEval(e, R_GlobalEnv, NULL); // -----> success UNPROTECT(1); // Function load SEXP fun; PROTECT(e = allocVector(LANGSXP, 3)); fun = findFun(ins...
2009 Jun 16
1
calling handlers within R_tryEval
Hello, When using R_tryEval (from JRI in my case), is there a way to setup error recovery strategy and more generally calling handlers. From my reading of context.c, R_tryEval calls R_ToplevelExec which creates a context like this: begincontext(&thiscontext, CTXT_TOPLEVEL, R_NilValue, R_GlobalEnv, R_BaseEnv, R_NilValue, R_NilValue); so I guess what I am trying to do is add "cend" and/or "handlerstack" to this context. Is this possible ? Are there examples of packages doing this ? Romain -- Romain Francois Independent R Consultant +33(0) 6 28 91...
2008 Aug 04
2
Parsing code with newlines
Dear List, When I try to parse code containing newline characters with R_ParseVector, I get a compilation error. How can I compile code that includes comments and newlines? I am using the following: void* my_compile(char *code) { SEXP cmdSexp, cmdExpr = R_NilValue; ParseStatus status; PROTECT (cmdSexp = allocVector (STRSXP, 1)); SET_STRING_ELT (cmdSexp, 0, mkChar (code)); PROTECT (cmdExpr = R_ParseVector (cmdSexp,-1,&status, R_NilValue)); UNPROTECT_PTR (cmdSexp); if (status != PARSE_OK) { return (void*)0; } e...
2009 Dec 10
1
switch() called with just the EXPR argument causes R to hang (PR#14124)
...all, SEXP op, SEXP args, SEXP rho) { int argval; SEXP x, y, w; x = eval(CAR(args), rho); if (!isVector(x) || length(x) != 1) error(_("switch: EXPR must return a length 1 vector")); PROTECT(w = switchList(CDR(args), rho)); if (isString(x)) { for (y = w; y != R_NilValue; y = CDR(y)) if (TAG(y) != R_NilValue && pmatch(STRING_ELT(x, 0), TAG(y), 1)) { while (CAR(y) == R_MissingArg && y != R_NilValue) y = CDR(y); UNPROTECT(1); return (eval(CAR(y), rho)); } for (y = w; y != R_NilValue; y = CDR(y))...
2009 Mar 03
1
profiler and loops
...EOF(fun) == SYMSXP ? CHAR(PRINTNAME(fun)) : "<Anonymous>"); } } so we can see it only cares about context CTXT_FUNCTION and CTXT_BUILTIN, when for loops play with CTXT_LOOP (this is again in eval.c within the do_for function) begincontext(&cntxt, CTXT_LOOP, R_NilValue, rho, R_BaseEnv, R_NilValue, R_NilValue); which as the name implies, begins the context of the for loop. The begincontext function looks like this : void begincontext(RCNTXT * cptr, int flags, SEXP syscall, SEXP env, SEXP sysp, SEXP promargs, SEXP callfun) { cptr-&g...
2023 Apr 16
0
sum(), min(), max(), prod() vs. named arguments in ...
...ed arguments other than 'na.rm' would be quite intrusive, since it is not uncommon to see do.call(sum, <named list>). > --- src/main/summary.c (revision 84252) > +++ src/main/summary.c (working copy) > @@ -419,6 +419,8 @@ > na_value = CAR(a); > if(prev == R_NilValue) args = CDR(a); > else SETCDR(prev, CDR(a)); > + } else if (TAG(a) && TAG(a) != R_NilValue) { > + warning("Named argument \"%s\" here is probably a mistake", CHAR(PRINTNAME(TAG(a)))); > } > prev = a; > } > > (Can TAG(a) eve...