(j3.2006) reduction routine

Bill Long longb
Thu May 20 10:44:10 EDT 2010



Malcolm Cohen wrote:

> 
> I must admit that if we're going to start adding special forms, I'd make array 
> reduction a special form too, I wouldn't make it use the general facility.
> 
> Viz
>   Call reduction(X, .myoper., ans)

This form would seem natural for the user.


> or even
>   Reduce(X) To (ans) Using(.myoper.)
> rather than
>   Call reduction(X, Resolve(Operator(.myoper.),Y,Z),ans)

This seems clunky, as noted before.  However, an alternate version would 
be to, in general, allow an actual argument be a generic name or the 
name of a operator (as in the first example above).  The cost is to add 
an attribute for the corresponding dummy argument

subroutine reduction (x, proc, ans)
...
   procedure(),resolve(x) :: proc


where the variables specified in the resolve() attribute can be other 
dummy arguments.  An explicit interface would be required for such a 
procedure.

If the actual argument is a procedure, then the resolve() attribute can 
be used to check the number and type of the arguments (assuming an 
interface for the actual argument is visible in the caller).

If the actual argument is a generic name, then the resolve() attribute 
is used by the caller to resolve the generic and the effective argument 
becomes the selected specific procedure.

If the actual argument is an operator, then the resolution is done based 
on a generic interface for that operator.

This scheme preserves a sensible call statement, yet seems to solve the 
problem.  There would be detailed wording to work out, but I prefer this 
style to the one proposed in 04-391.r1.


> 
> Anyway, I think that no special form is necessary - just have REDUCTION take a 
> procedure argument, and apply the procedure.  The user can write his own 
> function and have both genericity and dynamic dispatch applied within it should 
> that be what he wishes.  


This also occurred to me, and is the clear choice within the current rules.

Cheers,
Bill



-- 
Bill Long                                           longb at cray.com
Fortran Technical Support    &                 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