-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
why transfer-trick instead of class(*)? #5
Comments
I used the transfer approach because I find that use of Your comment about pointers is valid. I had originally intended for containers to hold only non-pointer values because I try to avoid pointers when I use Fortran (that way I don't have to worry about memory management). However, I have been thinking for some time that it would be useful to define a version of the container class which can use pointers. Likely both this and my existing implementation would then inherit from an abstract derived type. |
@cmacmackin Chris, thank you very much for your explanation. At that time I also relied on transfer because class() was not *mature. If you agree, I am going on with class() pointer, then when I'll feel this could be considered *stable I'll try to merge alongside the stantard allocatable storage in a complementary way. Cheers. |
I certainly don't mind. Could you please take the approach of using an On 02/10/16 13:23, Stefano Zaghi wrote:
Chris MacMackin |
Yes, @cmacmackin's suggestion is quite prudent, in my opinion. That way you can always use an (abstract) factory pattern to construct the desired instantiation of the object (transfer based or unlimited polymorphic) but then return a reference to an object of the parent abstract class. This way the client code is only exposed to the interface and not the implementation. |
@cmacmackin @zbeekman this is exactly what I planned to do. |
Hi @cmacmackin ,
I have restarted to study FIAT with hope to contribute to it. I am now going to develop an hash-table with the hope to merge into FIAT.
I am almost sure I have asked this already, but I do not remember your answer... sorry.
For your abstract container you encode data by transfer built-in, e.g.
I also used transfer-trick for generic list before
class(*)
becomes available in my main-stream compiler at that time. Now, I am wondering which are the advantages to prefer transfer-trick over the unlimited polymorphic data. For example I like to have the contained data defined as a pointer in order to avoid copy-in-copy-out every-time I manage the data (that in my application case could be large, order of 100MB). Moreover, you already use theselect type
cluttering-syntax for thetypeguard
method, thus the main cons ofclass(*)
is already accomplished.Currently, I am playing with something like
where the
associate_to_contents
is similar to yourtypeguard
, but performs only a pointer association.I would like to know your opinions, in particular what you think are the main pros of transfer-trick over class(*).
Cheers.
The text was updated successfully, but these errors were encountered: