-
Notifications
You must be signed in to change notification settings - Fork 4
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
Strong type checking in Fortran #39
Comments
This sound like a very nice feature. Contributions are welcome! |
Is it something urgent for @marcin? I think this should not take too long time to implement, and may improve also cosmo, doesn't it? |
@mbianco I am currently using manually implemented bindings, so no rush. It is more like a useful thing to have, IMO. |
I think this looks like an interesting feature. I would estimate 2 days (1 day prototyping + implementation, 1 day other work like integration in GT). |
I would suggest to develop this as a side thing, when someone needs a break from the main tasks |
Currently, when returning a complex type to Fortran
cpp_bindgen
always returnsbindgen_handle *
astype(c_ptr)
in Fortran. As a result, the actual type of the Fortran object is unknown and the user is allowed to pass the object to 'wrong' underlying C functions.This could be improved by returning a named derived type to fortran, and requiring that type in the generated Fortran bindings. For example, consider the following generated Fortran binding:
A binding with strong Fortran type checking could look like
This would make the fortran interfaces compile-time type safe.
Being able to use meaningful type names instead of a generic
bindgen_handle
would be very useful. That is, in the above case the programmer should be able to specify thevector_type
name somewhere in the C++ code, e.g., using a dedicated macro, or generic C++ capabilities.The text was updated successfully, but these errors were encountered: