Skip to content

Same Type As Requirement #19

Open
Open
@everythingfunctional

Description

@everythingfunctional

One thing that seems to come up frequently in generics (especially with what seems to be the quintessential example for Fortran), is specifying a "Trait" (or a "template" procedure) in such a way as two (or more) arguments must have the same type. For example, if I want to define a trait that requires the add function, in (psuedo)code, I'd like to have it look something like the following:

trait addable
  function add(x, y) result(z)
    type(addable), intent(in) :: x
    type(typeof(x)), intent(in) :: y
    type(typeof(x)) :: z
  end function
end trait

but (AFAIK), typeof only works for variables with a declared, specific type. I think it would make sense to have it work in this context, but it's something we should be thinking about.

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