For Programmers: Free Programming Magazines  


Home > Archive > Fortran > April 2005 > Re: Where should the type information be?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Where should the type information be?
beliavsky@aol.com

2005-04-01, 8:57 am

Andrew Reilly wrote:
> On Thu, 31 Mar 2005 20:50:58 -0500, Herman Rubin wrote:
>
> Many modern compilers will do constant propagation. If your pow

function
> is in-lined, then the constant propagation will follow naturally, and

you
> may end up with a similar result.
>
> What would be *really* nice would be a compiler that contained an
> interpreter, so that constant expressions that included (user

defined)
> functions could be evaluated to constants at compile time. Are there

any
> compilers that can do that already? (I'd be pretty surprised if

there
> wern't.)


In Fortran 2003 a broader range of expressions than before are allowed
in PARAMETER statements . This may partially address your wish. Quoting
the book "Fortran 95/2003 Explained", p303,

"A specification expresssion (used for an array bound or length type
parameter) may now reference a recursive function, so long as the
function does not invoke the procedure containing the specification
expression. Inside a derived-type definition, a specification
expression may also reference any type parameter of the type being
defined.

An initialization expression may now reference an elemental or
transformational standard intrinsic function, other than null, as long
as its arguments are all initialization expressions. This includes the
mathematical intrinsic functions (sin, cos, etc.).

For example,

real :: root2 = sqrt(2.0)

is now a valid initialization."

Someone on comp.lang.fortran likes to torture compilers with
complicated specification expressions. Often they break down under
severe pressure :).

Comp.lang.fortran added to follow-ups.

Greg Lindahl

2005-04-01, 8:57 pm

In article <1112352507.118855.162890@l41g2000cwc.googlegroups.com>,
<beliavsky@aol.com> wrote:

>In Fortran 2003 a broader range of expressions than before are allowed
>in PARAMETER statements . This may partially address your wish. Quoting
>the book "Fortran 95/2003 Explained", p303,


That isn't necessary to make the compile-time optimization. Fortran
compilers did this long before F2003.

-- greg

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com