(j3.2006) Asymmetry of REAL, CMPLX

Robert Corbett Robert.Corbett
Mon Jan 7 23:27:03 EST 2008

Van Snyder wrote:
> Assuming no KIND argument...
> Where REAL has a real, integer or BOZ argument, its result kind is
> default real.
> Where REAL has a complex argument, its result kind is the same as the
> argument.
> Where CMPLX has a complex, integer or BOZ argument, its result kind is
> default real.
> Where CMPLX has a real argument, its result kind is still default real,
> NOT the same as the argument.  This is the one that's singled out for
> unexpected behavior, and shouldn't be.
> REAL <=> COMPLEX ought to work consistently, not REAL => COMPLEX working
> one way, and COMPLEX => REAL working differently.
> Dan has pointed out that there have been other proposals for a new
> intrinsic, spelt COMPLEX e.g., that would provide symmetry.  That's just
> sugar for CMPLX with a KIND argument; it doesn't solve the real problem,
> which is the surprising asymmetry that costs time, money and
> reliability.

I am one of those who proposed providing a new intrinsic spelled
COMPLEX that would be symmetric.  In what sense does it not solve
the problem?

Once COMPLEX is provided, CMPLX could be deprecated and, eventually,
eliminated from the standard.  Of course, it would never be eliminated
from implementations.

Changing the current definition of CMPLX would be a disaster from an
implementor's POV.  It would require serious implementations to provide
an option to get the old behavior.  Given that most Fortran
implementations still provide a flag to make DO-loops always execute
their bodies at least once, the new option would be needed out to
effective eternity.

Bob Corbett

More information about the J3 mailing list