This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] polymorphic arrays


Le 06.08.2010 13:29, Janus Weil a écrit :

Hi Thomas,


1) Use the class container also for polymorphic arrays, and have the
"$data" field point to an array descriptor.

I have to confess my ignorance here, but...


Can different array elements have different types?  If so, this method
probably would not work.

no, IIUC all array elements must have the same dynamic type. (Btw your comment applies in the same way to the second option I proposed.)

To be honest, I have not found any direct statement on this in the
standard. But I would not know how to set up an array which has
different dynamic types, because:
[...]
I came to the same conclusion.

About your question Janus, I agree with Daniel K. that (1)[class container around array descriptor] seems a better approach for the same reasons he gives (more code reuse and thus less invasive changes to introduce dynamic type arrays, and the possibility to keep the OOP stuff not too on the middle-end side).

If the extra dereferencing of the class container's data field is too much of a concern, one can think of making it a non-pointer (i.e. making it the array descriptor directly).

In any case [(1) or (2)], it seems to me that either (or both) of the array descriptor and the middle-end code generation have to be changed: the actual size of the array elements may not be known at compile time, and have to be kept either in the descriptor or the class container so that array elements accesses can use it.
One can keep the existing non-polymorphic code unchanged with (1) while with (2)[array descriptors as class containers] the array descriptor _will_ be altered (even slightly).


If we choose to go (2) I would like to see the change made to the existing scalar OOP code before introducing polymorphic arrays.

Be realistic, vote (1). [And don't forget to donate ;-)]

Cheers
Mikael


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]