[Info-vax] LLVM, volatile and async VMS I/O and system calls
Dave Froble
davef at tsoft-inc.com
Mon Oct 4 12:23:05 EDT 2021
On 10/4/2021 2:32 AM, Simon Clubley wrote:
> On 2021-10-03, Dave Froble <davef at tsoft-inc.com> wrote:
>>
>> What I find a bit funny is all an optimizer does is corrects poorly
>> written code. People get into habits, and it can be hard to break some
>> habits.
>>
>
> Optimisers do quite a bit more than that. :-)
>
>> As an example, back in the day, the RSTS Basic+ interpreter had an
>> interesting quirk. For example:
>>
>> A = "abc"
>> B = A
>>
>> One would expect the value in A to be placed in the location where the
>> pointer to B points. However, Basic+ would change the pointer to B to
>> the value of the pointer to A, thus losing the old location of B. I
>> think this happened with strings, don't really remember, it has been a
>> very long time.
>>
>
> That's known as copy by reference instead of copy by value and has
> nothing to do with the optimiser. This is part of the language
> semantics and each language makes its own decisions in this area.
>
>> Now consider that the pointer to B was in an I/O buffer. After the
>> operation, B would no longer be pointing into the I/O buffer. Perhaps
>> not such a good thing. (Actually a horrible thing!)
>>
>> What people learned to do is:
>>
>> B = A + ""
>>
>> That would insure moving of the data, not the pointer. With BP2 and
>> later, this odd operation was not an issue. But, even today, I find
>> people still using that old habit of appending the null string to an
>> operation.
>>
>
> What that does is to create a custom string and point to it, thereby
> giving you the same end result as a copy by value.
>
> In some languages, you can force a copy by value on the original
> variable (and then you are into all the shallow copy versus deep
> copy fun. :-))
>
> Simon.
>
Can't you just agree that using such an operation when it is not
required is poor programming practice?
--
David Froble Tel: 724-529-0450
Dave Froble Enterprises, Inc. E-Mail: davef at tsoft-inc.com
DFE Ultralights, Inc.
170 Grimplin Road
Vanderbilt, PA 15486
More information about the Info-vax
mailing list