Skip to content

Add PWRXYZ: Prefer use <module> over include <source file> - #30

Draft
alvrogd wants to merge 1 commit into
mainfrom
feature/AddPWR074
Draft

Add PWRXYZ: Prefer use <module> over include <source file>#30
alvrogd wants to merge 1 commit into
mainfrom
feature/AddPWR074

Conversation

@alvrogd

@alvrogdalvrogd commented Jul 18, 2024

Copy link
Copy Markdown
Contributor

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

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

RRiva commented Sep 24, 2024

Copy link
Copy Markdown

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:

functionmat_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
endfunction

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.

@alvrogdalvrogd changed the title Add PWR074: Prefer use <module> over include <source file>Add PWRXYZ: Prefer use <module> over include <source file>Feb 20, 2026
Sign up for freeto 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.

2 participants

@alvrogd@RRiva