Re: Question about style [message #12390] |
Thu, 30 July 1998 00:00 |
David Foster
Messages: 341 Registered: January 1996
|
Senior Member |
|
|
Imanol Echave wrote:
>
> Hi people:
>
> In one of my programs I need to return some values, but every value is a matrix
> of diferent size and I can't make an array of matrix. The solution I've founded
> is to use an array of pointers pointing to the matrix. Do you think this is an
> ellegant way to do it? Has anyone a better idea?
This sounds perfectly reasonable to me; this is what pointers were
made for. I might suggest creating a structure containing the
pointers within your program, and then return that structure.
It's often easier to deal with data when it's encapsulated like
this. I often include a .status and .status_msg field so I can
return error codes and error messages within my structure.
Dave
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
|
|
|
Re: Question about style [message #12391 is a reply to message #12390] |
Thu, 30 July 1998 00:00  |
David Foster
Messages: 341 Registered: January 1996
|
Senior Member |
|
|
Imanol Echave wrote:
>
> Hi people:
>
> In one of my programs I need to return some values, but every value is a matrix
> of diferent size and I can't make an array of matrix. The solution I've founded
> is to use an array of pointers pointing to the matrix. Do you think this is an
> ellegant way to do it? Has anyone a better idea?
This seems perfectly reasonable to me; this is what pointers were
made for. I might suggest creating a structure to hold your pointers,
so the data is more encapsulated. I often add .status and .status_msg
fields so I can return error codes and error messages within my
structure.
Dave
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
|
|
|
Re: Question about style [message #12415 is a reply to message #12390] |
Wed, 29 July 1998 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Imanol Echave (ccaeccai@sc.ehu.es) writes:
> In one of my programs I need to return some values, but every value is a matrix
> of diferent size and I can't make an array of matrix. The solution I've founded
> is to use an array of pointers pointing to the matrix. Do you think this is an
> elegant way to do it? Has anyone a better idea?
I think this is a PERFECT way to do it. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|