I am aware one can use an interface to create a single name for multiple functions. In fact, I've done so in a small code for something like that:
interface assert_equal
procedure assert_equal_int
procedure assert_equal_real
procedure assert_equal_string
end interface
However, I noticed that most of the time I just need the first two dummy arguments of the function to implement some sort of equality. If I was trying to do this in Haskell, for instance, I would do something like
assertEqual :: (Eq a) => a -> a -> String -> IO ()
Where the first two arguments are the values being checked against each other and the third one is a message.
Or in Rust I would do, for instance
impl {
fn assert_equal<T>(expected: T, actual: T, msg: &str) where T: std::Eq {
...
# enter code here
}
}
Is there something similar or that at least emulates the same behaviour in Fortran? The current issue I am trying to solve is being able to do some sort of assert_equal
in derived types that I will create in my code base, without needing to define a specific subroutine for each derived type when they are going to look so similar