[RkWard-devel] new tests
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Mar 1 18:29:02 UTC 2007
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.
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?
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
> 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?
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.
Regards
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20070301/e73b69a5/attachment.sig>
More information about the Rkward-devel
mailing list