Suppose that I need to implement at least 5 queues in one procedure, each of it from a different defined type. How can achive this in a simple and short way?.
Anot
I have implemented the fortran template in Ruby, which is integrated in my CodeMate. The template syntax is similar to C++. I have implemented double linked list. The template definition snippets are as following:
...
template:list_t
type list_t
integer :: num_elem = 0
type(elem_t), pointer :: head, tail
contains
...
procedure :: insert => list_insert
...
end type list
...
template:list_insert@list_t
subroutine list_insert(this, elem, ...)
class(list_t), intent(inout) :: this
type(elem_t), intent(out), pointer :: elem
...
end subroutine list_insert
And the template instance is as following:
type(list_t) foo_list
where foo_t
is a user-defined type that extends list_elem_t
. The you can insert element into foo_list
by
call foo_list%insert(elem, ...)
I think my solution to Fortran template is natural.