Why should I use interfaces?

前端 未结 3 1795
轻奢々
轻奢々 2020-11-28 16:20

Whenever I program in Fortran I use modules and I don\'t have to worry about writing interfaces.

Now I\'m writing Fortran code to use inside R. The problem is that

3条回答
  •  执念已碎
    2020-11-28 16:50

    The main benefit is that the compiler can perform argument checks. This way, it can warn you about programming errors, which would be very hard to detect otherwise.

    Another very nice thing about interfaces is that you can bundle functions. Consider for example the sin function, which is defined for real and complex arguments of different kinds. Using interfaces, you can call the same function for different types of variables.

    For some features of modern Fortran such as function pointers, interfaces are (usually) required.

提交回复
热议问题