Specific binding

Syntax of a specific_binding

The form of specific binding is:

Read syntax diagramSkip visual syntax diagram
>>-PROCEDURE--+----------------------+-------------------------->
              '-(--interface_name--)-'   

>--+-----------------------+------------------------------------>
   +-,--attribute_list--::-+   
   '-::--------------------'   

   .-,------------------------------------------.   
   V  (1)                                       |   
>----------binding_name--+--------------------+-+--------------><
                         '-=>--procedure_name-'     

Notes:
  1. Fortran 2008
interface_name
defines the interface of the type-bound procedure. The interface_name must be the name of an abstract interface or of a procedure that has an explicit interface. If you specify an interface_name, you must not specify a procedure_name. An interface-name can appear if and only if the binding has the DEFERRED attribute.
attribute
A binding can have one or more attributes, called binding attributes. The same binding attribute cannot appear more than once for the same binding. The list of binding attributes that you specify in an attribute_list includes:
PASS
Defines the passed-object dummy argument of the procedure.
NOPASS
Indicates that the procedure has no passed-object dummy argument. If the interface of the binding has no dummy argument of the type being defined, use NOPASS. PASS and NOPASS can not both be specified for the same binding.
access_spec
Is PUBLIC or PRIVATE.
NON_OVERRIDABLE
Prevents a binding from being overridden in an extended type. You must not specify NON_OVERRIDABLE for a binding with the DEFERRED attribute.
DEFERRED
Marks the procedure as deferred. Deferred bindings must only be specified for derived type definitions with the ABSTRACT attribute. A procedure with the DEFERRED binding attribute must specify an interface_name. An overriding binding can have the DEFERRED attribute only if the binding it overrides is deferred. The NON_OVERRIDABLE and DEFERRED binding attributes must not both be specified for the same procedure. See Abstract types and deferred bindings (Fortran 2003) and Procedure overriding for more information.
binding_name
is the name of a binding of a type.
procedure_name
defines the interface of the type-bound procedure. The procedure_name must be the name of an accessible module procedure or an external procedure that has an explicit interface. If neither =>procedure_name nor interface_name appears, the procedure_name is the same as the binding_name. If =>procedure_name appears, you must specify the double-colon separator and an interface_name must not be specified.

Passed-object dummy arguments

A passed-object dummy argument applies to a type-bound procedure, or a procedure pointer component.

  • If you specify PASS (arg-name) the interface of the procedure pointer component or named type-bound procedure has a dummy argument with the same name as arg-name. In this case, the passed-object dummy argument is the argument with the given name.
  • If you do not specify PASS or NOPASS, or specify PASS without arg-name, the first dummy argument of a procedure pointer component or type-bound procedure is the passed-object dummy argument.

The passed-object dummy argument must be a scalar, nonpointer, nonallocatable dummy data object with the same declared type as the type being defined. All of its length type parameters must be assumed. The dummy argument must be polymorphic if and only if the type being defined is extensible.

In the example of a type-bound procedure with a specific binding, the type POINT contains a type-bound procedure with a specific binding. LENGTH is the type-bound procedure and POINT_LENGTH is the name of a module procedure.

Example of a type-bound procedure with a specific binding

MODULE smaple
TYPE :: POINT
   REAL :: X, Y
   CONTAINS
      PROCEDURE, PASS :: LENGTH => POINT_LENGTH
END TYPE

CONTAINS
   REAL FUNCTION point_length (a, b)

      CLASS (POINT), INTENT (IN) :: a, b
      point_length = SQRT ( (a%X - b%X)**2 + (a%Y - b%Y)**2 )

   END FUNCTION point_length
END MODULE


Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us