# Fortran: An ideal language for writing "Templates" of numerical algorithms (?)

**URL:** <https://fortran-lang.discourse.group/t/fortran-an-ideal-language-for-writing-templates-of-numerical-algorithms/2054>\
**Category:** Help\
**Created:** [October 12, 2021, 4:35am UTC](https://fortran-lang.discourse.group/t/fortran-an-ideal-language-for-writing-templates-of-numerical-algorithms/2054 "2021-10-12T04:35:46Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [October 12, 2021, 2:59pm UTC](https://fortran-lang.discourse.group/t/fortran-an-ideal-language-for-writing-templates-of-numerical-algorithms/2054/13 "2021-10-12T14:59:27Z")

</div>

I would also like to be able to return multiple values from a function, see the discussion here: [Syntax of interactive Fortran - #18 by certik](https://fortran-lang.discourse.group/t/syntax-of-interactive-fortran/1928/18)

We should create a standalone issue at the incubator repository to discuss this more.

I can see only one disadvantage: what if you use such a function in an expression? A short answer is that you would not be able to. The advantage is that it does not require any kind of a tuple type.

A long answer is that you could if we introduce a tuple type that would be the result. However, I would not, it seems it would open all kinds performance and design issues. Would it still be useful without a tuple type?

So a function that returns multiple values would indeed be similar to a subroutine. However, it is much more readable — you know exactly what are the “in” and “out” arguments. And since you cannot use a subroutine in an expression, it’s not a limitation that a function with multiple output values also cannot be.

---

_[View the full topic](https://fortran-lang.discourse.group/t/fortran-an-ideal-language-for-writing-templates-of-numerical-algorithms/2054)._
