Re: [Rd] PROTECT help

2012-03-27 Thread Terry Therneau
Brian & Duncan: Thanks. This was exactly what I needed to know. Terry On 03/27/2012 08:41 AM, Prof Brian Ripley wrote: On 27/03/2012 14:22, Terry Therneau wrote: I received the following note this AM. The problem is, I'm not quite sure how to fix it. Can one use PROTECT(coxlist(eval(PROTEC

Re: [Rd] PROTECT help

2012-03-27 Thread Duncan Murdoch
On 12-03-27 9:22 AM, Terry Therneau wrote: I received the following note this AM. The problem is, I'm not quite sure how to fix it. Can one use PROTECT(coxlist(eval(PROTECT , do I create an intermediate variable, or otherwise? I think both would work. The usual style in R sources is to us

Re: [Rd] PROTECT help

2012-03-27 Thread Prof Brian Ripley
On 27/03/2012 14:22, Terry Therneau wrote: I received the following note this AM. The problem is, I'm not quite sure how to fix it. Can one use PROTECT(coxlist(eval(PROTECT , do I create an intermediate variable, or otherwise? You can, but I find it easiest to follow if you create an interm

[Rd] PROTECT help

2012-03-27 Thread Terry Therneau
I received the following note this AM. The problem is, I'm not quite sure how to fix it. Can one use PROTECT(coxlist(eval(PROTECT , do I create an intermediate variable, or otherwise? I'm willing to update the code if someone will give me a pointer to the right documentation. This partic

Re: [Rd] PROTECT and OCaml GC.

2010-01-09 Thread Romain Francois
On 01/09/2010 02:04 AM, Guillaume Yziquel wrote: Guillaume Yziquel a écrit : Simon Urbanek a écrit : If you have suggestions for extending the API, feel free to post them with exact explanations how in general that extensions could be useful (general is the key word here - I think so far it wa

Re: [Rd] PROTECT and OCaml GC.

2010-01-08 Thread Guillaume Yziquel
Guillaume Yziquel a écrit : Simon Urbanek a écrit : If you have suggestions for extending the API, feel free to post them with exact explanations how in general that extensions could be useful (general is the key word here - I think so far it was rather to hack around your way of implementin

Re: [Rd] PROTECT and OCaml GC.

2010-01-08 Thread Guillaume Yziquel
Simon Urbanek a écrit : If you have suggestions for extending the API, feel free to post them with exact explanations how in general that extensions could be useful (general is the key word here - I think so far it was rather to hack around your way of implementing it). [And FWIW tryEval *is*

Re: [Rd] PROTECT and OCaml GC.

2009-12-01 Thread Guillaume Yziquel
Simon Urbanek a écrit : No, because you cannot use CHARSXP as a TAG. TAGs are always symbols. Therefore, logically, you must register it first in (or obtain from) the symbol table using install. OK. That's R side. OCaml side, I need to have as little side-effects as possible. Symbol assign

Re: [Rd] PROTECT and OCaml GC.

2009-12-01 Thread Simon Urbanek
On Dec 1, 2009, at 8:32 PM, Guillaume Yziquel wrote: > Simon Urbanek a écrit : >> You just pass it as value of the call. I suspect the reason it doesn't work >> is in your code, not in the facility (note that the link above is useless >> since the construction is mystery - if you were construct

Re: [Rd] PROTECT and OCaml GC.

2009-12-01 Thread Guillaume Yziquel
Simon Urbanek a écrit : You just pass it as value of the call. I suspect the reason it doesn't work is in your code, not in the facility (note that the link above is useless since the construction is mystery - if you were constructing it right, it would work ;)). Small example: SEXP myEval

Re: [Rd] PROTECT and OCaml GC.

2009-12-01 Thread Guillaume Yziquel
Guillaume Yziquel a écrit : Guillaume Yziquel a écrit : One last thing, concerning the use of promises. If I do install, findVar, without forcing the resulting promise, and then construct the call, I get a failure: Replacing findfun by findvar works in this specific case. See below. Could

Re: [Rd] PROTECT and OCaml GC.

2009-12-01 Thread Guillaume Yziquel
Guillaume Yziquel a écrit : One last thing, concerning the use of promises. If I do install, findVar, without forcing the resulting promise, and then construct the call, I get a failure: # R.eval_langsxp (R.langsxp_of_list [(R.symbol "str"); (R.symbol "lm")] 2);; Erreur dans function (objec

Re: [Rd] PROTECT and OCaml GC.

2009-12-01 Thread Guillaume Yziquel
Simon Urbanek a écrit : On Nov 30, 2009, at 16:07 , Guillaume Yziquel wrote: Simon Urbanek a écrit : And it goes then to my other question: How can you pass to eval a LANGSXP where the CAR is an *anonymous* function, no SYMSXP involved? You just pass it as value of the call. I suspect the r

Re: [Rd] PROTECT and OCaml GC.

2009-11-30 Thread Simon Urbanek
On Nov 30, 2009, at 16:07 , Guillaume Yziquel wrote: Simon Urbanek a écrit : And it goes then to my other question: How can you pass to eval a LANGSXP where the CAR is an *anonymous* function, no SYMSXP involved? You just pass it as value of the call. I suspect the reason it doesn't wor

Re: [Rd] PROTECT and OCaml GC.

2009-11-30 Thread Guillaume Yziquel
Simon Urbanek a écrit : And it goes then to my other question: How can you pass to eval a LANGSXP where the CAR is an *anonymous* function, no SYMSXP involved? You just pass it as value of the call. I suspect the reason it doesn't work is in your code, not in the facility (note that the link

Re: [Rd] PROTECT and OCaml GC.

2009-11-30 Thread Simon Urbanek
On Nov 30, 2009, at 13:14 , Guillaume Yziquel wrote: Simon Urbanek a écrit : Because I've been unable to find what exactly applyClosure or eval requires, when it comes to the structure of the argument LANGSXP. For example. LANGSXP is simply a pairlist representing the expression, e.g. to

Re: [Rd] PROTECT and OCaml GC.

2009-11-30 Thread Guillaume Yziquel
Simon Urbanek a écrit : Because I've been unable to find what exactly applyClosure or eval requires, when it comes to the structure of the argument LANGSXP. For example. LANGSXP is simply a pairlist representing the expression, e.g. to look at "a+2" expression: > .Internal(inspect(quot

Re: [Rd] PROTECT and OCaml GC.

2009-11-30 Thread Simon Urbanek
On Nov 30, 2009, at 12:08 , Guillaume Yziquel wrote: Simon Urbanek a écrit : You're talking about two entirely different things -- bypassing the API is a very bad idea, but it has nothing to do with your last paragraph. It's very good to hear that it's two different things. This has been

Re: [Rd] PROTECT and OCaml GC.

2009-11-30 Thread Guillaume Yziquel
Simon Urbanek a écrit : You're talking about two entirely different things -- bypassing the API is a very bad idea, but it has nothing to do with your last paragraph. It's very good to hear that it's two different things. This has been quite unclear to me. The API gives you access all use

Re: [Rd] PROTECT and OCaml GC.

2009-11-30 Thread Simon Urbanek
Guillaume, On Nov 29, 2009, at 13:57 , Guillaume Yziquel wrote: Simon Urbanek a écrit : On Nov 28, 2009, at 7:50 PM, Guillaume Yziquel wrote: FWIW what I think you should be really looking at is R_PreserveObject/R_ReleaseObject. OK. Thanks. I would suggest looking at the many other R embe

Re: [Rd] PROTECT and OCaml GC.

2009-11-29 Thread Guillaume Yziquel
Simon Urbanek a écrit : On Nov 28, 2009, at 7:50 PM, Guillaume Yziquel wrote: FWIW what I think you should be really looking at is R_PreserveObject/R_ReleaseObject. OK. Thanks. I would suggest looking at the many other R embeddings in other languages that already exist since I don't think

Re: [Rd] PROTECT and OCaml GC.

2009-11-29 Thread Simon Urbanek
On Nov 28, 2009, at 7:50 PM, Guillaume Yziquel wrote: > Whit Armstrong a écrit : >> I've had success w/ using a reference counting paradigm in which the outside >> memory manager calls UNPROTECT_PTR(R_object_); in its destructor. >> So, in my case (using c++ ) if objects are allocated on the heap

Re: [Rd] PROTECT and OCaml GC.

2009-11-28 Thread Guillaume Yziquel
Whit Armstrong a écrit : I've had success w/ using a reference counting paradigm in which the outside memory manager calls UNPROTECT_PTR(R_object_); in its destructor. So, in my case (using c++ ) if objects are allocated on the heap, which allocate R objects as their backend storage, I don't hav

Re: [Rd] PROTECT and OCaml GC.

2009-11-28 Thread Whit Armstrong
I've had success w/ using a reference counting paradigm in which the outside memory manager calls UNPROTECT_PTR(R_object_); in its destructor. So, in my case (using c++ ) if objects are allocated on the heap, which allocate R objects as their backend storage, I don't have to worry about out of ord

[Rd] PROTECT and OCaml GC.

2009-11-28 Thread Guillaume Yziquel
Hello. In the writing of my OCaml-R binding, I'm sort of confused when it comes to the use of the PROTECT and UNPROTECT macros. Basically, I have C stub functions that are in charge of calling R for everything. Here's a simple example: CAMLprim value r_findvar (value symbol) { /* The fin

Re: [Rd] protect

2006-05-23 Thread Kasper Daniel Hansen
Thank you very much, that was very helpful. Now I think I understand (parts of) the protection mechanism. /Kasper On May 23, 2006, at 9:03 PM, Prof Brian Ripley wrote: > On Tue, 23 May 2006, Kasper Daniel Hansen wrote: > >> Thank you very much. I think I do have a clearer understanding, >> b

Re: [Rd] protect

2006-05-23 Thread Prof Brian Ripley
On Tue, 23 May 2006, Kasper Daniel Hansen wrote: > Thank you very much. I think I do have a clearer understanding, but I have a > few questions > > On May 23, 2006, at 12:55 AM, Prof Brian Ripley wrote: > >> On Tue, 23 May 2006, Prof Brian Ripley wrote: >> >>> On Mon, 22 May 2006, Kasper Daniel

Re: [Rd] protect

2006-05-23 Thread Kasper Daniel Hansen
Thank you very much. I think I do have a clearer understanding, but I have a few questions On May 23, 2006, at 12:55 AM, Prof Brian Ripley wrote: > On Tue, 23 May 2006, Prof Brian Ripley wrote: > >> On Mon, 22 May 2006, Kasper Daniel Hansen wrote: >> >>> I have a few simple questions about the

Re: [Rd] protect

2006-05-23 Thread Prof Brian Ripley
On Tue, 23 May 2006, Prof Brian Ripley wrote: > On Mon, 22 May 2006, Kasper Daniel Hansen wrote: > >> I have a few simple questions about the usage of PROTECT, more >> specifically how careful one needs to be. Simple yes/no answers are >> fine. > > (Except that in the last case they would be misle

Re: [Rd] protect

2006-05-23 Thread Prof Brian Ripley
On Mon, 22 May 2006, Kasper Daniel Hansen wrote: > I have a few simple questions about the usage of PROTECT, more > specifically how careful one needs to be. Simple yes/no answers are > fine. (Except that in the last case they would be misleading.) > Most of the uses I have seen do protection wh

[Rd] protect

2006-05-22 Thread Kasper Daniel Hansen
I have a few simple questions about the usage of PROTECT, more specifically how careful one needs to be. Simple yes/no answers are fine. Most of the uses I have seen do protection when memory is allocated. But what if one just want to assign a value of another function to a variable. Say e

Re: [Rd] protect/unprotect howto in C code

2006-05-17 Thread Thomas Lumley
On Wed, 17 May 2006, Michael Dondrup wrote: > Thank you very much, Thomas! > > Thanks to the explanation, I think I could almost track down that bug. May I, > just for clarification, ask a further bunch of questions (sorry). From what > you say, did I get it right: > > - 'error in unprotect: stac

Re: [Rd] protect/unprotect howto in C code

2006-05-17 Thread Michael Dondrup
Thank you very much, Thomas! Thanks to the explanation, I think I could almost track down that bug. May I, just for clarification, ask a further bunch of questions (sorry). From what you say, did I get it right: - 'error in unprotect: stack imbalance' is only a warning, it will not cause ter

Re: [Rd] protect/unprotect howto in C code

2006-05-17 Thread Thomas Lumley
On Wed, 17 May 2006, Michael Dondrup wrote: > Hi, > > Im currently trying to debug a 'error in unprotect: stack imbalance' problem > and I am curious about two basic questions on the use of PROTECT and > UNPROTECT, which I could not figure out: > > - which objects have to be protected, namely, if

[Rd] protect/unprotect howto in C code

2006-05-17 Thread Michael Dondrup
Hi, Im currently trying to debug a 'error in unprotect: stack imbalance' problem and I am curious about two basic questions on the use of PROTECT and UNPROTECT, which I could not figure out: - which objects have to be protected, namely, if the code is something like: SEXP fun, e; /* get the ex

[Rd] PROTECT SEXP in stl map

2005-12-30 Thread finle014
Hello All, Im sure this question is basic but Im just getting started with R/c++ calls. I would like to use an standard template library (STL) map to organize some SEXP types in my program. The map is map paramMap. To insert values into the value portion of this map I make a call to the functio