[J3] [EXTERNAL] Re: 21-144r2

Clune, Thomas L. (GSFC-6101) thomas.l.clune at nasa.gov
Tue Jun 22 13:35:27 UTC 2021


Van,

I’m certainly not opposed to a more targeted swap facility.    But any generics solution ought to be powerful enough to provide similar functionality, albeit with less elegance.

I’m not immediately seeing a problem with finalization.

A generic subroutine could handle the disambiguation through additional template parameters.   This would, of course, preclude using SWAP in multiple contexts within the same scope without judicious use of rename.  But better rename than implementing and maintaining multiple template variations.   The latter would not be intolerable for SWAP, where the declarations outweigh the implementation and the whole package is small in any event.   But for more complex algorithms the usual problems with duplicated code would be a real concern.

Cheers,


  *   Tom

From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of j3 <j3 at mailman.j3-fortran.org>
Reply-To: j3 <j3 at mailman.j3-fortran.org>
Date: Monday, June 21, 2021 at 8:53 PM
To: j3 <j3 at mailman.j3-fortran.org>
Cc: Van Snyder <van.snyder at sbcglobal.net>
Subject: [EXTERNAL] Re: [J3] 21-144r2

On Tue, 2021-06-22 at 00:34 +0000, Shterenlikht, Anton via J3 wrote:

*quote*

ALG-1: Should the generics facility enable developers to define a

       scalar SWAP template that will apply to any type that supports

       assigment?  (YES, NO, UNDECIDED, ABSTAIN)

*end quote*

A swap statement has repeatedly been requested. Something like

x :=: y

for variables, and

x <=> y

for pointers.

Semantics can be debated. For example, if one is allocatable and the other not, how does that affect finalization? It's not obvious that this question even makes sense if SWAP is a generic subroutine because allocatability does not participate in generic resolution.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20210622/fcf979a9/attachment-0001.htm>


More information about the J3 mailing list