Re: derived types with parameter keyword
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Sun, 8 Feb 2009 13:13:24 -0800
wim <wim.van.hoydonck@xxxxxxxxx> wrote:
ifort complains along these lines:
m_unit.f90(21): error #6355: This binary operation is invalid for this
data type.
type(unit_t) , parameter :: velocity_unit = length_unit /
time_unit ! unit_t(0,1,-1)
where unit_t is a derived type with a defined operation for "/".
Any reason why this is not allowed/doesn't work?
I could quote the standard-speak to show what restrictions are violated,
but it can be explained more simply than that.
Parameters are intended to be computable at compile time. (The standard
doesn't use that terminology, but that's the idea). Your defined
operation involves executing a user-written procedure. You can't execute
user-written procedures at compile time. You have to wait until after
they have been compiled.
This isn't anything specific to derived types. You just happen to be
using a derived-type defined operation to reference the procedure. If
you tried any other way of referencing a user-written procedure to
define a parameter, that wouldn't work either.
Yes, one could in theory have some kind of compilation system that
allowed such things, but that would be much more complicated than the
relatively simple model of separation of compilation and execution that
Fortran and many other languages use.
--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
.
- Follow-Ups:
- Re: derived types with parameter keyword
- From: Larry Gates
- Re: derived types with parameter keyword
- From: Glen Herrmannsfeldt
- Re: derived types with parameter keyword
- References:
- derived types with parameter keyword
- From: wim
- derived types with parameter keyword
- Prev by Date: Re: Finding missed "D0" in numerical constants
- Next by Date: Re: derived types with parameter keyword
- Previous by thread: derived types with parameter keyword
- Next by thread: Re: derived types with parameter keyword
- Index(es):
Relevant Pages
|
Loading