Skip to content

Constant Expression Value Arguments for Generic Resolution #320

Open
@everythingfunctional

Description

@everythingfunctional

It has so far been impossible to write user defined functions that can mimic the behavior of various intrinsic functions. I.e.

function real(A, KIND)
  real, intent(in) :: A
  integer, intent(in) :: KIND
  real(KIND) :: real
end function

But if we had some mechanism to define a constant expression value that must be one of the arguments we could do it. I.e. some suggestive syntax

interface real
  module function str_to_real128(A, KIND, STAT)
    character(len=*), intent(in) :: A
    integer, parameter, intent(in) :: KIND = real128
    integer, intent(out), optional :: STAT
    real(real128) :: str_to_real128
  end function
  ...
end interface
...
real(real128) :: my_val
my_val = real("1.234", KIND=real128)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions