[Info-vax] LLVM, volatile and async VMS I/O and system calls
Simon Clubley
clubley at remove_me.eisner.decus.org-Earth.UFP
Mon Oct 4 02:32:31 EDT 2021
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.
--
Simon Clubley, clubley at remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.
More information about the Info-vax
mailing list