Type-bound procedures in Fortran allow binding functions to derived types, similar to methods in object-oriented languages. The tutorial demonstrates how to attach a distance function to a point_t type, making it callable directly on instances. Key concepts include using class() instead of type() for polymorphic arguments, maintaining both type-bound and normal procedure access, and proper naming conventions for module procedures. This approach enables encapsulation by keeping data components private while providing controlled access through bound procedures.

6m read timeFrom matthiasnoback.nl
Post cover image
Table of contents
EncapsulationType-bound proceduresFirst argument is the instanceType-bound and normal proceduresNaming procedures

Sort: