[RkWard-devel] new tests

Prasenjit Kapat kapatp at gmail.com
Thu Mar 1 21:35:56 UTC 2007


On Thursday 01 March 2007 01:29:02 pm Thomas Friedrichsmeier wrote:
> The problem being 
> that "i" and "var" are perfectly reasonable variable names that the user
> may have in the workspace, and so we should make sure, never to touch
> those. 

Is it not possible to create an environment for the variables used in RkWard, 
which does not interfere with the user's variable space? I thought it was 
possible, but haven't given much thought. I will try to dig up some more help 
pages and see.

> 1) change to use rk.temp.* names everywhere. I.e:
>
> rk.temp.i=0;
> for (rk.temp.var in rk.temp.objects) {
> 	rk.temp.i = rk.temp.i+1
> 	[...]
> 	rk.temp.results$'something'[rk.temp.i] <- something
> 	[...]
> }

This seems to be simlpe (but clumsy) solution.

> 2) use local, variant a)
>
> local({	# Do not place i and var in the workspace
> 	i=0;
> 	for (var in rk.temp.objects) {
> 		i = i+1
> 		[...]
> 		rk.temp.results$'something'[i] <<- something
> 		[...]
> 	}
> })

Instead of hardcoding local (..) into the php files, is it possible to run the 
whole php generated R code in a local(...) environment by default, without 
any the knowledge of the plugin writer? But of course documenting it 
somewhere. This way we might not need the cleanup() function in the php 
files.

> 3) use local, variant b)
> rk.temp.i=0;
> for (rk.temp.var in rk.temp.objects) {
> 	rk.temp.i = rk.temp.i+1
> 	local({	# Do not place i and var in the workspace
> 		i <- rk.temp.i
> 		var <- eval (rk.temp.var)
> 		[...]
> 		rk.temp.results$'something'[i] <<- something
> 		[...]
> 	})
> }

I think 1 or 2 are better that this !!

Regards
PK




More information about the Rkward-devel mailing list