From adrian at waddell.ch  Tue Aug 10 22:13:18 2010
From: adrian at waddell.ch (Adrian Waddell)
Date: Tue, 10 Aug 2010 16:13:18 -0400
Subject: [Rd] Adding Tcl source to an R package
In-Reply-To: <AANLkTinHstX-iJ_cNx7X2FokvtVBYMro-o9SZeFwsWbY@mail.gmail.com>
References: <4C61A971.10005@waddell.ch>
	<AANLkTinHstX-iJ_cNx7X2FokvtVBYMro-o9SZeFwsWbY@mail.gmail.com>
Message-ID: <4C61B2DE.7060805@waddell.ch>

On 08/10/2010 03:42 PM, Gabor Grothendieck wrote:
> On Tue, Aug 10, 2010 at 3:33 PM, Adrian Waddell <adrian at waddell.ch> wrote:
>> Dear R Community,
>>
>> I'm writing an R package with a lot of Tcl and Tk code. I use the Tcl
>> wrapper functions provided by the tcltk package if possible. However I
>> also define "pure" Tcl functions. I so far defined them with the .Tcl
>> function, for example (in R):
>>
>> .Tcl('proc test {a b} {
>>  return [expr {sqrt(pow($a,2)+pow($b,2))}]
>> }')
>>
>> so that I can use the procedures later on with either
>>
>> .Tcl('test 2 3')
>> or
>> tcl('test',2,3)
>>
>> My Question: Where can I put my procedures in a *.tcl file within my
>> package structure and how do I make my R package to load the Tcl
>> procedures? And will these functions be within a Tcl namespace?
>>
> 
> Look at the Rpad package for an example. It sources tcl code.

Thank you very much. For verification:

I have to load the tcl file within my R Code at some point with

tcl("source", tclfile)

where the tclfile variable is the path to my *.tcl file, in the Rpad
package created with

tclfile <- file.path(.find.package(package = "Rpad"), "tcl", "mini1.1.tcl")

Is there no tcl equivalent like useDynLib command in the NAMESPACE file
for C functions?



[Rd] Adding Tcl source to an R package
Adrian Waddell