search for: set_typeof

Displaying 10 results from an estimated 10 matches for "set_typeof".

2024 Jul 06
1
API for converting LANGSXP to LISTSXP?
On Fri, 5 Jul 2024 15:27:50 +0800 Kevin Ushey <kevinushey at gmail.com> wrote: > A common idiom in the R sources is to convert objects between LANGSXP > and LISTSXP by using SET_TYPEOF. However, this is soon going to be > disallowed in packages. Would you mind providing an example where a package needs to take an existing LISTSXP and convert it to a LANGSXP (or vice versa)? I think that Luke Tierney intended to replace the uses of SET_TYPEOF(allocList(...), LANGSXP) with allo...
2024 Jul 05
2
API for converting LANGSXP to LISTSXP?
Hi, A common idiom in the R sources is to convert objects between LANGSXP and LISTSXP by using SET_TYPEOF. However, this is soon going to be disallowed in packages. From what I can see, there isn't currently a direct way to convert between these two object types using the available API. At the R level, one can convert calls to pairlists with: > as.call(pairlist(as.symbol("rnorm"), 42)...
2008 Feb 19
1
level of mutability for the type of a SEXP
Dear list, I am writing C code to interface with R, and I would like to know the level of mutability for the type of a SEXP. I see that there is a macro/function TYPEOF(), and that it can be used as an l-value, as well as a macro/function SET_TYPEOF(). My question is "should the type be considered immutable, or it can it change after the SEXP has been created and used for a while ?". I understand that a call to TYPEOF will not perform any conversion, and my question is only about being sure that once the type of a given SEXP is set...
2008 Apr 05
2
Adding a Matrix Exponentiation Operator
...eger")); e = asInteger(y); if (e < -1) error(_("exponent must be >= -1")); else if (e == 1) return x; else if (e == -1) { /* return matrix inverse via solve() */ SEXP p1, p2, inv; PROTECT(p1 = p2 = allocList(2)); SET_TYPEOF(p1, LANGSXP); CAR(p2) = install("solve.default"); p2 = CDR(p2); CAR(p2) = x; inv = eval(p1, rho); UNPROTECT(1); return inv; } PROTECT(matrix = allocVector(mode, nrows * ncols)); PROTECT(tmp = allocVector(mode, nrows * ncols));...
2008 Mar 29
0
"Writing R Extensions": bad example with CAR / CDR as lvalues (PR#11054)
...e even better. Just in case you want to use it as example, here is my code. I hope it is correct in your expert eyes. /* Remove the variable with name s from the environment ev, i.e. construct the call: rm( list=s, envir=ev ) */ SEXP call; PROTECT( call = Rf_allocList( 3 ) ); SET_TYPEOF( call, LANGSXP ); SETCAR( call, install( "rm" ) ); SETCAR( CDR(call), allocVector( STRSXP, 1 ) ); SET_STRING_ELT( CAR( CDR(call) ), 0, mkChar( s ) ); SET_TAG( CDR(call), install("list") ); SETCAR( CDDR(call), ev ); SET_TAG( CDDR(call), install(&quot...
2024 May 13
1
[External] R hang/bug with circular references and promises
On Mon, 13 May 2024 09:54:27 -0500 (CDT) luke-tierney--- via R-devel <r-devel at r-project.org> wrote: > Looks like I added that warning 22 years ago, so that should be enough > notice :-). I'll look into removing it now. Dear Luke, I've got a somewhat niche use case: as a way of protecting myself against rogue *.rds files and vulnerabilities in the C code, I've been
2008 Mar 31
1
(PR#11054) "Writing R Extensions": bad example with CAR /
...u want to use it as example, here is my code. I hope it is > correct in your expert eyes. > > /* Remove the variable with name s from the environment ev, > i.e. construct the call: rm( list=s, envir=ev ) */ > > SEXP call; > PROTECT( call = Rf_allocList( 3 ) ); > SET_TYPEOF( call, LANGSXP ); > > SETCAR( call, install( "rm" ) ); > > SETCAR( CDR(call), allocVector( STRSXP, 1 ) ); > SET_STRING_ELT( CAR( CDR(call) ), 0, mkChar( s ) ); > SET_TAG( CDR(call), install("list") ); > > SETCAR( CDDR(call), ev ); > SET_TAG...
2024 Jun 14
0
R 4.4.1 is released
...* The non-API entry points Rf_setSVector, Rf_StringFalse, Rf_StringTrue and Rf_isBlankString have been added to those reported by R CMD check. * The new function Rf_allocLang is now available. This provides an alternative to the idiom of calling Rf_allocList followed by SET_TYPEOF. UTILITIES: * R CMD check now reports as warnings what gfortran calls 'Fortran 2018 deleted features', all of which have long been marked as 'obsolescent' and some of which were deleted in Fortran 2008 or earlier. Fortran compilers are no longer required t...
2024 Jun 14
0
R 4.4.1 is released
...* The non-API entry points Rf_setSVector, Rf_StringFalse, Rf_StringTrue and Rf_isBlankString have been added to those reported by R CMD check. * The new function Rf_allocLang is now available. This provides an alternative to the idiom of calling Rf_allocList followed by SET_TYPEOF. UTILITIES: * R CMD check now reports as warnings what gfortran calls 'Fortran 2018 deleted features', all of which have long been marked as 'obsolescent' and some of which were deleted in Fortran 2008 or earlier. Fortran compilers are no longer required t...
2024 Jun 14
0
R 4.4.1 is released
...* The non-API entry points Rf_setSVector, Rf_StringFalse, Rf_StringTrue and Rf_isBlankString have been added to those reported by R CMD check. * The new function Rf_allocLang is now available. This provides an alternative to the idiom of calling Rf_allocList followed by SET_TYPEOF. UTILITIES: * R CMD check now reports as warnings what gfortran calls 'Fortran 2018 deleted features', all of which have long been marked as 'obsolescent' and some of which were deleted in Fortran 2008 or earlier. Fortran compilers are no longer required t...