# Should we avoid assignment of derived types in robust programs?

**URL:** <https://fortran-lang.discourse.group/t/should-we-avoid-assignment-of-derived-types-in-robust-programs/2359>\
**Category:** Uncategorized\
**Created:** [December 2, 2021, 8:59am UTC](https://fortran-lang.discourse.group/t/should-we-avoid-assignment-of-derived-types-in-robust-programs/2359 "2021-12-02T08:59:37Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [December 6, 2021, 4:16pm UTC](https://fortran-lang.discourse.group/t/should-we-avoid-assignment-of-derived-types-in-robust-programs/2359/11 "2021-12-06T16:16:56Z")

</div>

Yes, the verbosity of associate can be a nuisance. (But not necessarily worse than restricting yourself to calling subroutines everywhere.) Perhaps the standard could introduce a second form of associate, which implicitly terminated at the end of functions, subroutines, and blocks (I think there was a thread about this).

I don’t have an answer at hand for the second point.

Concerning your follow-up comment, in the past I was playing around with an iterator like idea for a list of integers (strings) and using associate to retrieve a pointer:

- [Behavior of associate construct in gfortran](https://fortran-lang.discourse.group/t/behavior-of-associate-construct-in-gfortran/782)

I think it has some elements of what you are asking for. (The main idea is to keep the type hidden, but have a function which returns a pointer to a target that can be used in an associate statement.)

---

_[View the full topic](https://fortran-lang.discourse.group/t/should-we-avoid-assignment-of-derived-types-in-robust-programs/2359)._
