(j3.2006) defining a type with no components

Bill Long longb
Thu Apr 17 18:03:20 EDT 2014


On Apr 17, 2014, at 2:17 PM, Dan Nagle <danlnagle at ME.COM> wrote:

> Hi,
> 
> Following this morning?s discussion, consider:

Assuming something like

module modu

> 
> type :: no_comp
> end type no_comp
> 
contains

> function foo() result( bar)
> type( no_comp) :: bar
> end function foo
> 
end module modu

so that the type definition is visible in the function?

> A compiler that warned that bar is not defined
> upon return is spurious?  No?
> 

The current requirement is "If the result variable is not a pointer, its value shall be defined by the function.?   Already partly lame, since ?values? don?t get defined, variables do.  But editing to ??it shall be defined by the function?  is still a bit vague in this case as to what is meant by ?by the function?.  Is the simple act of including a declaration sufficient to cause the result to ?be defined by the function??   It was not really any action (executable statement) that caused the definition, but rather the nature of the type that causes the definition.  Certainly compilers can be trained to make an exception in this case and not issue a message.  But I?m not sure that is helpful for the user (assuming a much longer function).  But then the user is probably confused already if they wrote this.

Suppose the function result is polymorphic with a declared type of no_comp.  In SELECT TYPE constructs within the function, the block for type = no_comp would not require an assignment to the variable bar, whereas the other blocks would (assuming they corresponded to types that added actual components). Complicates the above compiler message issue, but not insolvably.

Cheers,
Bill



> --
> 
> Cheers!
> Dan Nagle
> 
> 
> 
> 
> 
> 
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Bill Long                                                                       longb at cray.com
Fortran Technical Suport  &                                  voice:  651-605-9024
Bioinformatics Software Development                     fax:  651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101





More information about the J3 mailing list