Re: [Rd] Pb with defineVar() example in the "Writing R Extensions" manual

2008-01-16 Thread Herve Pages
Peter Dalgaard wrote: > Herve Pages wrote: [...] >> So everybody seems to assume that SET_ELEMENT(), SET_STRING_ELT(), >> SET_NAMES(), etc... can't (and will never) trigger garbage collection. >> But what about defineVar()? More generally, how do I know this for the >> functions/macros listed in Rd

Re: [Rd] Pb with defineVar() example in the "Writing R Extensions" manual

2008-01-16 Thread Peter Dalgaard
Herve Pages wrote: > Peter Dalgaard wrote: >> >> That's not the problem you raised (argument evaluation order), but >> there's a CONS inside defineVar, and as far as I can see, it doesn't >> protect its arguments, so you could well be right. >> > > This problem is related to my original proble

Re: [Rd] Pb with defineVar() example in the "Writing R Extensions" manual

2008-01-16 Thread Herve Pages
Peter Dalgaard wrote: > Herve Pages wrote: >> Hi Peter, >> >> Peter Dalgaard wrote: >> >>> Herve Pages wrote: >>> Hi, I'm wondering if this code from the "Writing R Extensions" manual is really safe: SEXP mkans(double x) { SEXP ans;

Re: [Rd] Pb with defineVar() example in the "Writing R Extensions" manual

2008-01-16 Thread Peter Dalgaard
Luke Tierney wrote: > On Wed, 16 Jan 2008, Peter Dalgaard wrote: > >> Herve Pages wrote: >> Hi Peter, >> >> Peter Dalgaard wrote: >> >>> Herve Pages wrote: >>> Hi, I'm wondering if this code from the "Writing R Extensions" manual is really safe: SEXP mkans(double

Re: [Rd] Pb with defineVar() example in the "Writing R Extensions" manual

2008-01-16 Thread Luke Tierney
On Wed, 16 Jan 2008, Peter Dalgaard wrote: Herve Pages wrote: Hi Peter, Peter Dalgaard wrote: Herve Pages wrote: Hi, I'm wondering if this code from the "Writing R Extensions" manual is really safe: SEXP mkans(double x) { SEXP ans; PROTECT(ans = allocVector(REA

Re: [Rd] Pb with defineVar() example in the "Writing R Extensions" manual

2008-01-16 Thread Peter Dalgaard
Herve Pages wrote: > Hi Peter, > > Peter Dalgaard wrote: > >> Herve Pages wrote: >> >>> Hi, >>> >>> I'm wondering if this code from the "Writing R Extensions" manual >>> is really safe: >>> >>> SEXP mkans(double x) >>> { >>> SEXP ans; >>> PROTECT(ans = allocVecto

Re: [Rd] Pb with defineVar() example in the "Writing R Extensions" manual

2008-01-16 Thread Herve Pages
Hi Peter, Peter Dalgaard wrote: > Herve Pages wrote: >> Hi, >> >> I'm wondering if this code from the "Writing R Extensions" manual >> is really safe: >> >> SEXP mkans(double x) >> { >> SEXP ans; >> PROTECT(ans = allocVector(REALSXP, 1)); >> REAL(ans)[0] = x; >

Re: [Rd] Pb with defineVar() example in the "Writing R Extensions" manual

2008-01-16 Thread Peter Dalgaard
Herve Pages wrote: > Hi, > > I'm wondering if this code from the "Writing R Extensions" manual > is really safe: > > SEXP mkans(double x) > { > SEXP ans; > PROTECT(ans = allocVector(REALSXP, 1)); > REAL(ans)[0] = x; > UNPROTECT(1); > return ans

[Rd] Pb with defineVar() example in the "Writing R Extensions" manual

2008-01-15 Thread Herve Pages
Hi, I'm wondering if this code from the "Writing R Extensions" manual is really safe: SEXP mkans(double x) { SEXP ans; PROTECT(ans = allocVector(REALSXP, 1)); REAL(ans)[0] = x; UNPROTECT(1); return ans; } double feval(double x, SEX