(j3.2006) reduction routine

Bill Long longb
Wed May 19 16:01:33 EDT 2010



Van Snyder wrote:
> This is one of the reasons that I proposed in 04-391r1 to provide a
> means to resolve a generic name without evaluating arguments of invoking
> the specific procedure to which it is resolved.
> 
> On Wed, 2010-05-19 at 08:06 -0700, Bill Long wrote:
>> Suppose you wanted to have an intrinsic that did a general reduction 
>> operation, such as
>>
>> call reduction (array, operation, result)
>>
>> where there is an intrinsic or defined operation specified by the 
>> 'operation' argument that is visible in the caller scope.
>>
>> How would you actually specify the operation to the routine?  In the old 
>> days, one would have just passed the name of the procedure that performs 
>> the operation as the actual argument.  In the new OOP world, all you 
>> would know is a generic specifier or a symbolic operator name.  You 
>> could write
>>

If I read 04-391r1 correctly


>>   call reduction (X, ".my_oper.", ans)
>>

would turn into

call reduction (X, resolve (operator(.my_oper.),X,X), ans)

Not sure if that is less or more clunky, but it is something that could 
be standardized in a more general way.

Cheers,
Bill



>> where you expect the compiler to look up (or, for polymorphic variables, 
>> generate code to look up) the function corresponding to the operator 
>> .my-oper. that is defined for a variable of the dynamic type of X, and 
>> then pass that on to the actual reduction routine.  [Such a scheme would 
>> only work for an intrinsic, so that the compiler 'knows' what to do.] 
>> This is a bit clunky, but appears to work.
>>
>> Is there a better method?
>>
>> Cheers,
>> Bill
>>
>>
>>
> 
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3

-- 
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