-
Notifications
You must be signed in to change notification settings - Fork 16
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
Extend move_alloc to unlimited polymorphic variables #345
Comments
There's certainly something to be done here. I'm not quite sold on the stat argument approach, but it's not terrible. We could also do some sort of carve out in the select type construct. |
I'm unable to think of a good reason why the selector can't have the ALLOCATABLE or POINTER attributes within a |
Even if there ain't a reason, the nested select type statements needed are an eyesore: select type(a1)
type is (heavy_type)
select type(a2)
type is (heavy_type)
call move_alloc(from=a1,to=a2)
end select
end select |
I see your point, but the inner |
The selector does have the ALLOCATABLE or POINTER attribute, but the associate-name is what has the correct type, and it doesn't have the allocatable or pointer attributes because it might be associated with the result of an expression. |
Let me try again. I can't think of a good reason why the associate-name |
Originally discussed here: https://fortran-lang.discourse.group/t/ownership-for-fortran-pointers/8084/55?u=ivanpribec
The proposal would be to provide a means of move allocation from unlimited polymorphic to other allocatable variables (assuming that the types are consistent).
The standard currently says in 11.1.3.3
Just a thought, perhaps the semantics of
move_alloc
could be extended, such that:would apply to any two allocatable variables including polymorphic ones. When types don't belong to the same hierarchy, it should obviously fail. In the case that
from
andto
are both polymorphic it requires some thought of what should happen allocating from child to parent (some data members would be destroyed) or parent to child (some data members would remain uninitialized).cc @everythingfunctional @gronki
The text was updated successfully, but these errors were encountered: