Richard Maine <nos...@see.signature> wrote:
(snip, I wrote)
>> PL/I, originating in the early 1960's at a time when a favorite
>> Fortran error was modifying a constant actual argument, supplies
>> modifiable temporaries for constants and parenthesized actual
>> arguments.
>> To me, that is a nice simple rule. You know what the compiler is
>> doing, why it is doing it, and what it allows you to do.
>> So, why does Fortran not use definable temporaries?
(snip)
> You might have different preferences, but I don't see what is hard to
> explain about it. Maybe you find it hard to explain *WHY* that is the
> case, but I don't see it as hard at all to explain what the facts are.
> Expressions are not definable. Ever.
(snip on VALUE attribute)
> For what its worth, and at the risk of inciting the wrath of our
> favorite proponent of PL/I as the perfect solution to everything, I'll
> note that the PL/I way regularly confused me and resulted in me writing
> buggy code. I several times got caught by changing the value of a local
> copy when I intended to change the value of the actual argument. Yes,
> I'm sure someone will point out that this labels me as a slow learner. I
> would say that the Fortran default makes sense to me if only because the
> vast majority of the time that one changes the value of a dummy
> argument, one intends for it to also change the actual. It certainly
> does happen that one sometimes wants a modifyable copy that doesn't
> propogate back to the actual, but I consider this the minority case.
OK, one feature of PL/I is the ability to specify the many different
attributes of a variable, or write a constant with appropriate attributes.
This complicates the passing of arguments and conveniently, with
appropriate prototypes, PL/I will convert arguments for you.
Compilers I knew were good at giving warning messages in that case,
as the argument conversion is one way.
Personally, I found it better than what Fortran did, and I presume
still does, pass the bits of the wrong type of argument, but I can
see that it can cause problems.
Note, for example, that to PL/I FLOAT BINARY(50) and FLOAT BINARY(51)
are distinct data types, even though they both might have the same
machine representation. In contrast, Fortran
REAL(SELECTED_REAL_KIND(14))
and
REAL(SELECTED_REAL_KIND(15))
are likely the same data type, which you can test
by testing the values of SELECTED_REAL_KIND.
I am not sure by now in which cases the compiler will do a one-way
conversion.
It could be more obvious, such as passing a fixed point variable
to a floating point dummy.
> I made that eror in my PL/I code a lot larger percentage of the time
> than I made the converse error in my Fortran code.
If actual and dummy arguments agree in attributes, there should be
no conversion. But often enough, they don't.
For another interesting conversion case, is the case of ENTRY
statements, PL/I will oonvert the return value to one with
the appropriate attributes for the specific ENTRY point.
(It is probably better not to use ENTRY points with different
attributes, though.)
Fortran, as I understand it, EQUIVALENCEs the return values.
> (And no, I won't debate this with Robin. I won't actually debate it with
> anyone actually. Just content to point out that I have a different
> perspective on it. Some people can civilly accept that different
> perspectives exist. Other people... have a harder time with that.)
Yes, I won't debate with him, though I do have fun replying sometimes.
-- glen