From peter.meilstrup at gmail.com  Sat Dec 14 21:43:54 2013
From: peter.meilstrup at gmail.com (Peter Meilstrup)
Date: Sat, 14 Dec 2013 12:43:54 -0800
Subject: [Rd] internal manipulation of ...
In-Reply-To: <26F53C67-F7E8-4C0F-85F3-6C50E4F87168@r-enthusiasts.com>
References: <EDC77346-95D8-4562-A49C-889109F5DF92@r-enthusiasts.com>
	<CABdHhvE_TodiJp5pzBYWdQKn3QuKHSwJ62xwun2-cG3tX04EKQ@mail.gmail.com>
	<26F53C67-F7E8-4C0F-85F3-6C50E4F87168@r-enthusiasts.com>
Message-ID: <CAJoaRhb5JTJ16SO2qpfBT43xeStcysVe1z9yyPGgictcJo-YrQ@mail.gmail.com>

In R code, get("...", environment()) will retrieve the DOTSXP object.
So another way is to write your wrapper functions like

someFunc <- function(...) {
  .External("someFunc_extern", get("...", ifnotfound=NULL) )
}

If you're trying to mimic what substitute() et al do, you'll sometimes
need to follow a chain of promises-that-have-promises in the PREXP
slot until you get to the "real" one.

Peter

On Sat, Dec 14, 2013 at 6:12 AM, Romain Fran?ois
<romain at r-enthusiasts.com> wrote:
> Thanks. This works for me. See this gist: https://gist.github.com/romainfrancois/7959531
>
> Romain
>
> Le 13 d?c. 2013 ? 01:09, Hadley Wickham <h.wickham at gmail.com> a ?crit :
>
>> Could you pass the environment and then look for the object called ... in it?
>>
>> f <- function(...) {
>>  .Call("my_fun", environment())
>> }
>>
>> I think (and may well be wrong) that you can use standard tools to
>> find the DOTSXP object in that environment.
>>
>> Hadley
>>
>>
>> On Thu, Dec 12, 2013 at 2:32 PM, Romain Fran?ois
>> <romain at r-enthusiasts.com> wrote:
>>> Hello,
>>>
>>> I?m looking for examples on how to manipulate the ... internally, e.g. in a .Call or .External function.
>>>
>>> I?m particularly interested in accessing the environment in which each contribution to ... can be evaluated.
>>>
>>> So far, I?m using tricks involving passing down the sys.calls() and sys.frames() down to the C function. The documentation in http://cran.r-project.org/doc/manuals/R-ints.html#Dot_002ddot_002ddot-arguments did not help me a lot.
>>>
>>> Romain
>>> ______________________________________________
>>> R-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>
>>
>> --
>> http://had.co.nz/
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] internal manipulation of ...
Peter Meilstrup