On 22-Apr-2004, Jens Ruecknagel <address@hidden>
wrote:
| Why is count a attribute of octave_value? Why is ref *octave_value?
| Shouldn't it be: count attribute of octave_base_value and |
octave_value::ref* octave_base_value?
| Wouldn't it be better to make octave_value the proxy class and |
octave_base_value the referenced class? It is used this way anyway?
| | I'm just curios? Does anybody know the reason, I did not think of?
I think I followed the structure of the Number class hierarchy in
Coplien's "Advanced C++; Programming Styles and Idioms" book from
1992. I must admit that at the time, that code seemed quite complex
to me, so probably I copied a lot more than I really understood.
Looking at the code now, I think the rep object must be a pointer to
an octave_value object so that the virtual functions in the
octave_value class work properly.
If you see another way to do this that is better, then please submit a
complete working example that demonstrates your ideas. It can be
greatly simplified compared to the octave_value classes (for example,
just two derived types and one or two operations on them). You could
start with the code in the first attachment below, and fix it so that
it works correctly. Currently, both calls to the functions in main
end up in the methods of base_value class when only the one for
type_two should. When you are done, I think you will probably end up
with something much like what is in the second attachment, which is a
simplified version of the current octave_value hierarchy. But maybe
there is a simpler and better way that I'm not seeing. In any case,
going through the exercise yourself will probably help you to
understand why things are the way they are.
jwe
------------------------------------------------------------------------