[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copying objects



In article <820s03$t1b$1@usenet.bham.ac.uk>,
	James Tappin <sjt@star.sr.bham.ac.uk> writes:
> Is there a "clean" way to make a copy of an object. The best I could do for a
> nice easy case with no pointers or object references in the class was:
> 
> pro Object1::set_all, tstr
> for i = 0, n_tags(tstr)-1 do self.(i) = tstr.(i)
> end
> 
> function Object1::copy
> temp = {object1}
> for i = 0, n_tags(temp)-1 do temp.(i) = self.(i)
> newobj = obj_new('object1')
> newobj -> set_all, temp
> return, newobj
> end
> 
> While it works,  it seems to be a bit of a kludge. Is there a better way?


I don't think there is more general way to do this other than to
have IDL do it internally, but this would be difficult since objects
can contain other objects, pointers, pointers-to-pointers, etc.  
I suggested this to RSI during 5.3 beta testing, but basically the
answer was "no way."  During some email exchanges regarding object
encapsulation, I was told something very interesting, however.  Although
it violates encapsulation, it is possible to return a pointer to object
internal data, thus preventing copying of large datasets.  However, one
could then modify the object data from outside the object itself - not
good object-oriented programming. 

I was told by RSI that (paraphrasing) that "there is not much 
enforcement of encapsulation for the present, but it may be tightened 
in future releases of IDL; there may come a time when returning a pointer 
will not longer work."  Oops!  Maybe that should be added to the 
IDL documentation :-)

While I am on the subject of RSI beta testing support, I find that 
I am again frustrated by the beta testing procedure.  Almost all bugs and
feature requests I submitted are unaddressed in the 5.3 release version.  
The problem of plotting of log scales with less than 1 decade still 
remains - a bug report I have submitted faithfully since 1995! 
I realize that IDL is a huge package, and must require *a lot* of work
to maintain and upgrade, but this is not the first time this has 
happened, and I have to ask myself "what's the point in beta testing, and
taking the time to document possible errors for submission?"
I'd be interested in hearing other people's experiences with the
beta program, or RSI support in general.

Ok, I'm done complaining now.  Back to IDL programming :-)

Regards,

-bob





-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Robert S. Mallozzi                                       256-544-0887
                                                      Mail Code SD 50
http://gammaray.msfc.nasa.gov/           Marshall Space Flight Center 
http://cspar.uah.edu/~mallozzir/                 Huntsville, AL 35812
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~