Re: defining an arbitrary type in your newer Fortrans



Ancient_Hacker <grg2@xxxxxxxxxxx> wrote:

Jan, I'm no fan of C, but "typedef" is (slightly) more than a #define,
there is a little bit of compiler intelligence. Not much, but enough
to (barely) do the job.

I don't see anything directly comparable in Fortran.

A typealias feature like this was proposed for f2003. Not only was it
proposed, it was accepted. I was even a fairly big fan of it for a
while. But I backed off and supported pulling it out of the drafts... as
did a majority. The main reason (anyway my main reason, and it seemed to
be the telling argument for many in my judgement) was that typealias
didn't do enough to actually achieve the stated objective.

Yes, it would be nice to be able to say HighPrecisionFloatingType (or
something a bit shorter :-)). I had some vision that this would allow
you to write code, the bulk of which was independent of whether this was
an alias for an intrinsic real kind or, on a machine that lacked native
support for enough precision, a derived type.

But the feature just doesn't come close to achieving that. As you say,
C's typedef has a slight bit more "intelligence", but it still isn't
really enough. I don't recall the list of things that don't work out,
but it was pretty long. Basically the feature completely fails in the
goal of looking like a separate type instead of like a macro with a few
small smarts.

Start with literal constants. I/O in general. Generic disambiguation.
And lots of other things.

I wanted this feature, but I couldn't even come close to seeing how to
make it actually work as other than an incomplete kludge. Might about as
well go the preprocessor route. The smarts thatmight be sad, as you do
above, to barely do the job in C, are not adequate to do it in Fortran.
I might elaborate on why I think there is a difference, but I'll steer
clear of that direction.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.



Relevant Pages

  • Re: F200x (was Re: When to expect a F2003 compiler?)
    ... Most of the features of Fortran 90 ... to what extent to committee members qualify as people? ... >> feature to provide a really useful capability. ...
    (comp.lang.fortran)
  • Re: Fortran Error Reporting Requirements (Was: GFORTRAN PROBLEM WITH SAVE STATEMENT)
    ... was originally intended to be part of Fortran 95. ... exceptions, including integer-related exceptions. ... that ENABLE blocks would greatly slow down execution speeds on some processors. ... I liked the ENABLE block feature and I would have liked to have seen it ...
    (comp.lang.fortran)
  • Re: C or Fortran
    ... Fortran 95 is almost entirely backwards compatible with earlier ... My meaning was that each time a new feature is added, ... strictly following F77 standards. ... That is even more true of a very high-level language like Matlab. ...
    (comp.soft-sys.matlab)
  • Re: Namelist correctness question
    ... > I also don't see this feature in VS Fortran, ... it was an undocumented feature of IBM fortran. ... (reading partial arrays) ...
    (comp.lang.fortran)