- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve, why is it that the TYPE keyword was needed? The double colon alone would have made it clear we were referring to a type.
So instead of
TYPE(FOO) :: variable
We could have just had:
FOO :: variable
Does the ability to declare TYPE or CLASS dummy arguments improve performance? To me its seams unnecessary to have this complication of arguments being converted to and from polymorphic and that it would worsen performance.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes it is simpler but I will note double colon is optional in which case it maybe become ambiguous.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not every change in the standard is for performance - indeed most are there to improve programmer productivity. Sure, anything that defers decisions to runtime will reduce performance, (CLASS does this, TYPE does not), but polymorphism greatly simplifies some aspects of programming and appears in many other languages.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is a long and deadly boring discussion on the difference between Fortran and FORTRAN on the Fortran discourse forum. It echoes rather badly the excellent points made by Steve.
If you need the program to run faster, it is usually much more cost effective to buy a better computer. A Intel CORE i9 with bells and whistles like the Old No 9 train is merely 3200 USD. Less than the cost of a programmer for a week. Or you get a special Fortran computer and do not put anything else on it.
Really you only need LISP and FORTRAN, everything else is just cake, but human beans make lots of cakes, some good and some excellent, in cake terms you need LISP and FORTRAN, the rest is just a nice sugar on the top to improve programming productivity.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Additionally, there are no "reserved" words in Fortran and therefore code such as the following shall be conformant:
type pointer
integer :: n = 42
end type
type(pointer), allocatable :: a !<-- imagine this instruction without TYPE()
allocate( a )
print *, a%n
end
C:\temp>gfortran -ffree-form p.f -o p.exe
C:\temp>p.exe
42
C:\temp>ifx /free /standard-semantics p.f
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2023.2.0 Build 20230627
Copyright (C) 1985-2023 Intel Corporation. All rights reserved.
Microsoft (R) Incremental Linker Version 14.36.32537.0
Copyright (C) Microsoft Corporation. All rights reserved.
-out:p.exe
-subsystem:console
p.obj
C:\temp>p.exe
42
Now, imagine the instruction on line 4 without `TYPE(..)` enclosure.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@FortranFan wrote:Additionally, there are no "reserved" words in Fortran
Quite true (I wrote about that here), but you can't declare your own derived type that has the same name as an intrinsic type, and you are allowed to name intrinsic types in a type() declaration.
C734 (R727) A derived type type-name shall not be DOUBLEPRECISION or the same as the name of any intrinsic type defined in this document.
R703 declaration-type-spec is intrinsic-type-spec
or TYPE ( intrinsic-type-spec )
or TYPE ( derived-type-spec )
or TYPE ( enum-type-spec )
or TYPE ( enumeration-type-spec )

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