r - Complex object initialization scope issues with nested functions -
OK, so I'm trying to use S4 classes to create a very complex object, in which the slots With half a dozen matrix, some lists, and possibly a kitchen sink or two there. The object is started by referring to a configuration object and opening it, which I have already defined, it is easy to define the class with I SetClass (), but in the setMethod ("Start") Difficulty finding a great way to set up slots.
The problem is that I need to set specific elements of those half-a-dozen matrix based on the parts of those configurations. For each element of the configuration object, I have to set specific elements of several metrics. Note that the matrix functions are in the scope / environment to start. Then I've nested the function within the start of that function, which is the actual assignment for the matrix, or anyway the idea. Those functions can certainly see , but they can not modify because the
Unfortunately, these nested functions have to modify several metrics, so assigning assignments to return values and main initial work is not practical or elegant. (But this is possible, if I filled the copies of matrices in the list returned and then added them to the main initialization function. Strange though, and a lot more additional code would be required.)
(Which must stop this scoping problem) is not very practical due to the categorized nature of the configuration object, which actually wants to go through recursive calls.
The last option I can think of is to use it to assign an assignment to a non-lock variable to assign it with the envir option () function. But using such an environment like icky, like a goto statement ...
So, what is the most pirate approach? Stick with pure functional programming and pass unnecessary metrics to inappropriate data structures inappropriately? Try to find an iterative solution that totally avoids the task? Use deep magic by playing with the environment?
Did you & lt; & Lt; -
? This makes the parent a little easier in the environment.
Comments
Post a Comment