[J3] [BULK] Re: [EXTERNAL] Should all intrinsic functions be simple?

Malcolm Cohen malcolm at nag-j.co.jp
Thu Dec 21 02:53:02 UTC 2023


Tom:

> SIMPLE procedure that plays games with TEAMS

 

Pretty hard to do since image control statements are forbidden in SIMPLE, so one SIMPLE procedure execution is thereby all in the same segment as the calling statement.

 

Tom:

>the trig functions are not SIMPLE…?

Brad:

> I don't know that I want to go that far

 

Tom did not go far enough. All floating-point arithmetic depends on the rounding mode (that is kind-of the whole point of having a rounding mode!). 

 

Here is the example you should be thinking of, not SIN or COS or any other intrinsic.

 

SIMPLE REAL FUNCTION ADD(X,Y)

REAL,INTENT(IN) :: X,Y

ADD = X + Y

END FUNCTION

 

Nearly always gives different answers for sufficiently different rounding modes.

 

Brad:

> the Fortran definitions of PURE and SIMPLE aren't quite what people coming from other backgrounds might intuit

 

That’s certainly true for PURE, though my recollection is that there is not universal and complete agreement on all the fine details of “pure”.

 

But surely no-one should be confused by SIMPLE, as we did not hijack an existing jargon term, we only hijacked an ordinary English word. No-one will know what it means without reading our definition. (Well, it might be an obscure jargon term I’ve forgotten, or never heard before, but it is surely not widely understood if so.)

 

Damian:

> the standard doesn't guarantee that simple procedures are deterministic

 

Actually I think they are usually deterministic. That word does not mean “does not depend on the rounding mode”. The ones that are not deterministic are ones that evaluate stuff in parallel and combine them in an unpredictable order, like a multi-threaded SUM might do.

 

I really do not see any problem here that would be helped by a NOTE. The vast unwashed masses that don’t understand floating-point, or don’t understand environments, are still going to be confused whatever we write.

 

Cheers,

-- 

..............Malcolm Cohen, NAG Oxford/Tokyo.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20231221/26a1aeef/attachment.htm>


More information about the J3 mailing list