Skip to content

Precision API strategy: wp-only getters vs sp/dp/qp convenience interfaces #18

@lukaswittmann

Description

@lukaswittmann

Context

fclap currently treats real(wp) as the float precision.

Problem

This improves consistency, but it also means users cannot do:

real :: x
call args%get("factor", x)

when x is not real(wp) (e.g. wp=dp, x=sp) this will fail at compile time ( as its not matching any specific binding).

Discussion

Should fclap remain strict wp-only for generic get, or provide explicit convenience APIs for other kinds (sp, dp, qp) without reintroducing generic ambiguity?

Options

  • Keeping get strictly at real(wp) will require explicit conversion by users and setting wp in fclap; this is IMO not desirable.
  • Add separately named conversion helpers (e.g. get_real_sp, get_real_dp, optional get_real_qp) while keeping generic get as wp-only; that would be a middle ground, but also IMO not very nice.
  • Provide full multi-kind generic overloads (sp, dp, qp) across the API. This would allow every CLI argument to have its specific precision up to the wish of any user. Of course, at the cost of having to add interfaces for every real entry point in src/fclap/fclap_namespace.f90 which would make the API much larger, and test and maintenance more painful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions