-
Notifications
You must be signed in to change notification settings - Fork 16
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
Constant Expression Value Arguments for Generic Resolution #320
Comments
Nice idea. I modified your example to say |
Actually I did mean |
Same as #91 I think? |
Very similar, yes, but I think the solution I propose is different. |
@everythingfunctional I see --- you had there "str" in the function call, but "real" as the interface. Everything is clear now after your edit. |
A mechanism like the integer, parameter, intent(in) :: KIND = real128 we'd write,
similar to PDTs. |
My idea was more along the lines of that argument being required and required to have the given value (so the compiler can actually do the code generation), but it can then be used for generic resolution. This is a bit with an eye towards one of the generics features being worked on so you could do something like:
You could also use a feature like this to disambiguate between allocatable or not like a bunch of people seem to want to lately. I.e.
|
A typo here? Was the following that was meant? ..
real(KIND) :: str_to_real128
.. |
Given my idea, and that interface, they're equivalent. |
Agree totally. The clause (or call it an attribute if one prefer) of |
This comment was marked as spam.
This comment was marked as spam.
I like this proposal. It would be helpful in writing numeric types which are closer to intrinsic floating and integer types (for instance big ints or emulate floats) For instance if one implements quad-precision type using double-double:
it would make it easier to write generic code if it could be extended to work with the conversion routines:
Would it make sense to also allow resolution using a (constant) enumerator? |
I don't see why not. They're basically integers. |
It has so far been impossible to write user defined functions that can mimic the behavior of various intrinsic functions. I.e.
But if we had some mechanism to define a constant expression value that must be one of the arguments we could do it. I.e. some suggestive syntax
The text was updated successfully, but these errors were encountered: