[J3] dumb question about module use not inheriting into interfaces
Vipul Parekh
parekhvs at gmail.com
Sat Aug 27 21:48:31 UTC 2022
On Fri, Aug 26, 2022 at 10:14 PM Gary Klimowicz <gak at dancingbear.dev> wrote:
> ..
> I might be confused by your suggestion, Vipul, but I don't see how
> anything like this is realistically possible with current compiler
> technology.
>
Gary,
Consider the following in a file named foo.f90:
module m
use, intrinsic :: iso_c_binding, only : c_int, c_char, c_float
type, bind(C) :: t
integer(c_int) :: x
end type
contains
subroutine foo( a ) bind(C, name="foo")
real(kind=c_float) :: a(*)
end subroutine
subroutine bar( b ) bind(C, name="bar")
integer(kind=c_int), value :: b
end subroutine
subroutine baz( c ) bind(C, name="baz")
character(kind=c_char, len=1) :: c(*)
end subroutine
subroutine qux( d ) bind(C, name="qux")
type(t) :: d
end subroutine
end module
And a practitioner does 'gfortran -fc-prototypes -fsyntax-only foo.f90 >
foo.h'. She then gets (in addition to some fluff) in foo.h:
typedef struct t {
int x;
} t;
void bar (int b);
void baz (char *c);
void foo (float *a);
void qux (t *d);
And can think "hmm.. the reverse i.e., a C prototype to Fortran interface
can be achieved too and why not in situ"!
Perhaps the compiler folks at Clang are only interested in doing what is
easiest and the least effort to support Fortran, but there is no mention of
"compiler" under Terms and Definitions in the standard.
And you know well with the Fortran standard, a processor .NE. compiler.
Surely J3 can work together to further the vision of Backus where "being
lazy" has gotta be the deciding trait of practitioners such that a
*processor* can be standardized where function prototypes only need to
written down once:
https://thenewstack.io/how-john-backus-fortran-beat-machine-codes-priesthood/
This appears viable, it is a matter of not limiting to what can be done
with the compiler but developing a broader vision as to what a *processor*
can do.
Regards,
Vipul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20220827/d9faffe2/attachment.htm>
More information about the J3
mailing list