Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

22-120r2 Generics formal requirements: Overcoming strong concept clunkiness #73

Open
zjibben opened this issue Mar 3, 2022 · 2 comments

Comments

@zjibben
Copy link
Member

zjibben commented Mar 3, 2022

L. A template may not use any procedures or operators except those
that have been specified in a REQUIRES statement.
Rationale: This is the notion of a "strong concept" which allows
template developers to ensure that a template does not
have any implicit requirements that might not be
detected for some unanticipated template parameters.

A colleague at LANL recently told me strong concepts sound cumbersome, in certain scenarios. For instance, if you have a deep tree of templated code, and you need to call a new function at the bottom, it's necessary to add a requirement for that interface at every level of the call stack. In some sense this is like passing data by argument, but this would be especially tedious when temporarily introducing extra operations for debugging purposes. Has subgroup discussed ways to mitigate this?

@tclune
Copy link
Member

tclune commented Mar 3, 2022

Subgroup has discussed the issue, but ... guidance from our outside expert is that we should not poke holes in the system. One solution would be for compilers to simply provide a switch which deprecates violations of STRONG to merely a warning.

One related issue which has not quite been addressed is PRINT, WRITE, and READ. These are not procedures and thus are not currently disallowed in the specs, but ... they would be difficult to use in most templates. And I imagine that they will be appropriately constrained by the time we are done with the feature.

@zjibben
Copy link
Member Author

zjibben commented Mar 3, 2022

I see, yes this seems a fundamental cost to strong concepts (though not necessarily an overriding cost). A compiler switch would be a fair solution for debugging, assuming that's feasible for vendors to consider.

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

No branches or pull requests

2 participants