[J3] [EXTERNAL] Re: New intrinsic XXX_PREFIX and XXX_SUFFIX procedures

Clune, Thomas L. (GSFC-6101) thomas.l.clune at nasa.gov
Fri Jan 27 14:14:10 UTC 2023


Further, I thought the intent was to support “exotic” scans using user defined functions.


  *   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: Thursday, January 26, 2023 at 10:49 PM
To: Van Snyder <van.snyder at sbcglobal.net>, j3 <j3 at mailman.j3-fortran.org>
Cc: Brad Richardson <everythingfunctional at protonmail.com>
Subject: [EXTERNAL] Re: [J3] New intrinsic XXX_PREFIX and XXX_SUFFIX procedures

Hi Van,

Ok, I see. That's certainly an interesting idea, but I think I'd rather just introduce specialized scan functions. I.e. SCAN_SUM. The enumerator thing has no precedent in Fortran (AFAIK).

Regards,
Brad

On Thu, 2023-01-26 at 17:06 -0800, Van Snyder wrote:
On Thu, 2023-01-26 at 23:52 +0000, Brad Richardson via J3 wrote:
Hi Van,

I'm not quite sure I understand the use case your suggesting. What would it mean to provide an enumerator as an OPERATION? Can you provide an example?

Assume there is an enumeration type SCAN_OPERATIONS in ISO_Fortran-Env, and one of the enumerators is SCAN_SUM. then you'd invoke the SCAN instrinsic using

SCAN ( ARRAY, SCAN_SUM )

As I mentioned in reply to Tom's question, if the OPERATION isn't a function, it ought to be an enumerator, i.e., a constant, so the processor knows which scan to do at compile time. If you want it to be a run-time selection, use the form in which OPERATION is a function, and put your decision inside of it.

Alternatively, one could allow the OPERATION to be a variable of the enumeration type, with a note that this might be less efficient because the processor doesn't know which operation to do at compile time. It's kine of like the processor optimizing sqrt(2.0) when it sees that, instead of

  x = 2.0
 print *, sqrt(x)

Regards,
Brad

On Thu, 2023-01-26 at 10:45 -0800, Van Snyder via J3 wrote:
On Thu, 2023-01-26 at 16:52 +0000, Brad Richardson via J3 wrote:
I've been pondering this more, and I think the way I'd like to propose
this is as a single new intrinsic. I think it could in theory be named
SCAN, as the interface would be fully distinguishable from the existing
SCAN intrinsic for character set membership search. The interface would
be:

SCAN(ARRAY, OPERATION[, IDENTITY, DIM, MASK, SEGMENT, EXCLUSIVE,
REVERSED, ORDERED])

There should be two varieties of OPERATION. One would be an enumerator of an enumeration type defined in ISO_Fortran_Env. The other would be a two-argument function provided by the user.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20230127/5aa9073d/attachment.htm>


More information about the J3 mailing list