# Functional programming in Fortran

**URL:** <https://fortran-lang.discourse.group/t/functional-programming-in-fortran/849>\
**Category:** Uncategorized\
**Created:** [March 17, 2021, 1:56am UTC](https://fortran-lang.discourse.group/t/functional-programming-in-fortran/849 "2021-03-17T01:56:04Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [April 25, 2021, 6:51pm UTC](https://fortran-lang.discourse.group/t/functional-programming-in-fortran/849/6 "2021-04-25T18:51:55Z")

</div>

It would be convenient if each ASSOCIATE did not have to be paired with END ASSOCIATE. In this case the ASSOCIATE block would terminate at the end of the program unit. Then, in Fortran, you would have a simple way to define variables that cannot be changed, and you could use the type inference of ASSOCIATE to avoid declaring many variables. Currently if you use ASSOCIATE for each variable you define, you must clutter the end of the program unit with many END ASSOCIATE statements. For example, it would be nice if the program

```
implicit none
associate (pi => 3.14)
associate (r => 10.0)
print*,"Radius, circumference =",r,2*pi*r
end associate
end associate
end

```

were valid without the two END ASSOCIATE statements. In this case, pi and r could be defined in the same ASSOCIATE statement since they are independent, but often the variable you want to define depend on variables that must be defined in previous ASSOCIATE statements.

If people think this idea has merit I can submit it to [j3-fortran](https://github.com/j3-fortran)/ **[fortran\_proposals](https://github.com/j3-fortran/fortran_proposals)**

---

_[View the full topic](https://fortran-lang.discourse.group/t/functional-programming-in-fortran/849)._
