[RkWard-devel] new tests

Stefan Roediger stefan_roediger at gmx.de
Thu Mar 1 20:46:03 UTC 2007


Am Donnerstag, 1. März 2007 19:29 schrieb Thomas Friedrichsmeier:
> Hi Stefan,
>
> haven't looked at much, yet. One thing I already noted before, but never
> found the time to type up:
>
> You've added several tests with a pattern like:
>
> i=0;
> for (var in rk.temp.objects) {
> 	i = i+1
> 	[...]
> 	rk.temp.results$'something'[i] <- something
> 	[...]
> }
>
> Plugins using this pattern have existed before (in fact, probably I'm at
> fault myself for creating this pattern some time ago, but I can't
> remember), and we've released this sort of code before. However, I think we
> really need to get rid of this, sooner rather than later. 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. I'd suggest, we try to come up with an acceptable solution for this
> problem, before you add more plugins of this type, as else, they'd all need
> to be fixed, later.
>

I see. Will be changed soon!

> Let's have a look at our options (there may be more, but these are the ones
> I can think of):
> 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
> 	[...]
> }
>
> Advantages: No advanced statements needed.
> Drawbacks: "Ugly", lengthy code (number of lines remains constant, but
> length of lines is increased)
>
> 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
> 		[...]
> 	}
> })
>
> Advantages: i and var can be used, safely
> Drawbacks: Use of advanced constructs "local" and "<<-" (may be alleviated
> by the above comment). Two more lines of code (but short ones), additional
> level of indentation needed.
>
> 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
> 		[...]
> 	})
> }
>
> Advantages: can use i and var as shortcuts; Not quite as much additional
> indentation
> Drawbacks: Four more lines of code compared to 1. All the drawbacks of 2.
>
> Personally, I tend to 1 or 2, with a slight preference for 2 (but uncertain
> of this). Further options, opinions?

I'll test and you will see. This will take a couple of days. Further options, 
opinions? Right now no.

>
> On Thursday 01 March 2007 00:20, Stefan Roediger wrote:
> > They turn out to be very useful so maybe worth for you to keep them in
> > mind. Thomas you wrote a lot of such functions. Is there a documentation
> > for them?
>
> No, there isn't (anybody volunteering to dig into how to write Rd files?).
> Or actually, some have one or two lines of comment above them in
> rbackend/rpackages/rkward/R/public.R

Do not know. Maybe I find the time maybe not. Threfore for the moment let it 
put us on the ToDo list.
To address questions regarding the usage one can also look how they are used 
in other plug-ins. ...

>
> > On my ToDo list are still:
>
> [...]
>
> > Is somebody else planing to work on some of these?
>
> Just a suggestion: Should we keep this sort of coordination info in the
> wiki?

Yes.

> I guess it might be easier to have a single page with such info, than 
> potentially having to pick it from several mail-threads. Also, this page
> could have "ideas for plugins" that you don't plan to start working on,
> yourself, anytime soon. We could then establish a guideline to - before
> starting work on a new plugin - check this page, and "claim" whatever
> plugins you intend to work on in the short term.

okay

>
> Regards
> Thomas

Kind regards
Stefan




More information about the Rkward-devel mailing list