- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If a contained procedure passes the object, it must be passed as a polymorphic variable (CLASS rather than TYPE) if the derived type is extendable. This isaccording to the error message we get if trying to pass using TYPE.
There could be a speed benefit in being able to pass the object as TYPE and often we may not need to allow the object definition to be extendable.
Is there an attribte we can set to say that a derived type is not extendable ?
There could be a speed benefit in being able to pass the object as TYPE and often we may not need to allow the object definition to be extendable.
Is there an attribte we can set to say that a derived type is not extendable ?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
BIND(C) or SEQUENCE make a type not extensible. But such a type cannot have type bound procedures. BIND(C) types also cannot have procedure pointer components. I think sequence types can, but I've never gone there.
If an object is of a type that is not extensible, then the obj%binding syntax for a procedure reference is just syntactic sugar that lets you put the PASS'ed argument out the front before the % (if there's no extensibility, there's no polymorphism, so no runtime selection of the procedure to call). In that case you might as well just reference the procedure using a normal "F90" function or subroutine reference.
(To put it another way - "contained procedures" are type bound procedures. If you don't need type bound procedures (i.e. you don't need polymorphic behaviour), then don't use them!)
If an object is of a type that is not extensible, then the obj%binding syntax for a procedure reference is just syntactic sugar that lets you put the PASS'ed argument out the front before the % (if there's no extensibility, there's no polymorphism, so no runtime selection of the procedure to call). In that case you might as well just reference the procedure using a normal "F90" function or subroutine reference.
(To put it another way - "contained procedures" are type bound procedures. If you don't need type bound procedures (i.e. you don't need polymorphic behaviour), then don't use them!)

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page