Skip to content

Templates for functions/subroutines #4

Open
@certik

Description

@certik

A very common request is to allow templates for subroutines or functions, in order to allow code like the following:

    <T> function f(x)
    <T>, intent(in) :: x
    f = x + 1
    end function

instead of

interface f
    module procedure f_int
    module procedure f_single
    module procedure f_double
end interface

contains

    integer function f_int(x) result(f)
    integer, intent(in) :: x
    f = x + 1
    end function

    real function f_single(x) result(f)
    real, intent(in) :: x
    f = x + 1
    end function

    real(dp) function f_double(x) result(f)
    real(dp), intent(in) :: x
    f = x + 1
    end function

More use cases available at https://github.com/certik/fortran-generics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Clause 15Standard Clause 15: ProceduresFortran 202yProposals targeting the standard after F2023unsubmittedHas not been submitted to the committee yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions