-
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
Function kind specified by optional input #91
Comments
@jacobwilliams wrote:
The specific example with 'my_class_size' function above is not feasible since KINDs need to be known at compile time. However, based on further description of the need, it may be possible to workaround it by designing the 'my_class' as a parameterized derived type. Anyways, the need "I want to be able to define a function that behaves like, for example, the intrinsic SIZE function" is yet another instance where the Fortran standard makes certain allowances for intrinsic procedures (generic like ABS, FINDLOC, etc; variadic like MAX, MIN) and intrinsic types that are inextensible, single-component like C_PTR, etc. but does not extend the same courtesy for user procedures and types This really comes to 'bite' because the committee refuses to include certain intrinsic 'classes' (a la what other languages now already have e.g., C++ in STL with std::string, std::vector, std::variant) that are so badly needed in the language but then there is extreme recalcitrance to offer to coders all the tools and mechanisms they need to build their own such 'classes'. |
I have stumbled into this a few times already. The last time was in a discussion of extending the intrinsic character functions like Allowing a mechanism to allow a For a specific example say I want to use a derived type designed to emulate quadruple precision (106 bits of significand) using two doubles (also known as double-double arithmetic) or potentially the more ambitious quad-double (unevaluated sum of 4 doubles):
To allow easily porting code from double to double-double, I would like to overload the
If no optional argument is present, then
Is there any way to find out if any related proposals have been discussed previously, and if yes, why were they rejected? |
@ivan-pi , I don't recall ever seeing a proposal along these lines. It's an interesting idea. |
I think this proposal is very similar to #128. |
Similar, but not the same. |
I want to be able to define a function that behaves like, for example, the intrinsic
SIZE
function, where the kind of the output is specified by an optional input. Am I correct that this currently isn't possible?Maybe using something similar to @cmacmackin's parameterized function syntax from #4, combined with a better way to specify the default value of optional arguments (see also #22):
See also #78, and also the various issues about generic programming and templates.
The text was updated successfully, but these errors were encountered: