Skip to content

Conversation

@alvrogd
Copy link
Collaborator

@alvrogd alvrogd commented Jul 18, 2024

Just the entry and example codes. The benchmark will be added soon.

@alvrogd alvrogd self-assigned this Jul 18, 2024
@alvrogd alvrogd changed the title PWR074: Add entry and code examples Add PWR074: Prefer use <module> over include <source file> Jul 18, 2024
@RRiva
Copy link

RRiva commented Sep 24, 2024

Hi @alvrogd, in general this is a nice idea, but sometimes include is exactly what is needed. A use case of include is to implement poor man generics. For example:

function mat_op(a) result(y)
real :: a(..)
real :: y

select rank(a)
  rank(0)
    include 'long_expression_that_is_rank_agnostic.f90'
  rank(1)
    include 'long_expression_that_is_rank_agnostic.f90'
  rank(2)
    include 'long_expression_that_is_rank_agnostic.f90'
end select
end function

A similar, more concrete, example is provided at this implementation of a generic list. In this case, the code depends on a compiler directive. Therefore, it cannot be compiled and used until that is specified.

Just to be clear, there are plenty of cases where this PR makes sense (mostly old F77 code), but distinguishing the cases where include must be kept might be difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants