It might be useful to have both C/C++ programmers and Fortran programmers compare and contrast pointers in these two languages.
In trying to explain to C/C++ programmers how Fortran pointers differ, I usually say pointers to functions or subroutines do not exist. I then try to make the argument that Fortran pointers are more "higher-level", but the details are fuzzy.
What exactly is the difference?
Best How To :
As Mark says, pointers to functions and subroutines certainly do exist in Fortran. The differences are:
- In C, pointers are just an address whereas in Fortran, a pointer can have additional information such as array bounds and strides, which is why an explicit interface is required when declaring a pointer dummy argument
- In C, you have to explicitly dereference a pointer, whereas in Fortran the dereferencing is automatic (except in contexts where a pointer is required)
- In C, there are no assumptions about aliasing, whereas in Fortran you're only allowed to point to things that have the TARGET attribute