From: Adam Beneschan on
On Mar 19, 11:02 am, Simon Wright <si...(a)pushface.org> wrote:
> tmo...(a)acm.org writes:
> > IIRC, the Burroughs 6500 had what they called a "cactus stack" where
> > branching would occur for new threads.  And there was a Texas Instruments
> > microprocessor that had no real stack, but rather a set of registers
> > that could be saved to RAM on a subroutine call.
> > These preceded DOS.
>
> The PDP-8 worked like that; the JMS instruction stored the return
> address in the first word of the subroutine, execution started at the
> next word.
>
>    JMS FOO    / CALL SUBROUTINE FOO
>
>    FOO, +0    / STORED RETURN ADDRESS
>    ...
>    JMP I FOO  / RETURN
>
> (we only had capitals)
>
> --S

Isn't that approximately how all computers used to work? Or at least
a lot of them? When I was first learning how computers ran, it seemed
like the common thing was for jump instructions to save the address of
the next instruction in a register, and then the subroutine code would
store the register somewhere---perhaps in the location containing the
return jump, since I don't remember those computers having "indirect
jump" instructions either. It was a few years before I encountered a
machine that automatically saved return addresses on a stack---or even
had a concept of a stack built into it.

One thing I remember was a particular computer's implementation of
COBOL (Honeywell 200/2000 series---my dad used to work for Honeywell
so those were some of the computers I was most familiar with). COBOL
used PERFORM statements for subroutine calls, and since you could have
PERFORM A in one part of the program and PERFORM A THROUGH B in
another part, or you could just fall into A without a PERFORM, the
paragraph A couldn't tell whether it was supposed to return to the
caller at the end of the paragraph. So the code, before it did a
PERFORM A, would do a "move" to move a branch instruction into a
location at the end of A that would branch back to the caller. Then,
after it returned, it would do another "move" to move a no-op to that
location.

Of course, none of these were good with recursion but I don't think
the experts understood the importance of recursion back then.

-- Adam


From: Jerry on
On Mar 19, 1:22 pm, "Jeffrey R. Carter"
<spam.jrcarter....(a)spam.acm.org> wrote:
> Brian Drummond wrote:
>
> > But code using the array can be written as normal, with a "my_array ... renames
> > my_array_ptr.all" clause to hide the pointer.
>
> Generally, after something like
>
> A : constant Array_Ptr := new Array_Type [(Low .. High)];
>
> You can use A just as if it were the array itself:
>
> B := A (A'First);
> A (A'First) := A (A'Last);
> A (A'Last) := B;
>
> --
> Jeff Carter

That is true when accessing array elements and slices but not for
indicating the entire array as a single entity such as in a subroutine
argument, e.g.

y := cos(x);

or

z := x + y;

with

function "+" (Left, Right : Real_Vector) return Real_Vector;

which is from ARM G.3.1.

Using access variables without renaming, the above line would have to
be written

y := cos(x.all);

and

z.all := x.all + y.all;

and in the algebraic-like calculations that are possible using
overloads the .all's clutter up the equation a bit. It's just a matter
of where you want to put the eye pollution. I have an extensive
library of subroutines including overloads that work with Real_Vector
and Complex_Vector from G.3 and either way (renaming or .all-ing)
works fine but on balance I think renaming is easier to read (and
probably easier to forget to release memory 8^( .)

Jerry
From: Jeffrey R. Carter on
Jerry wrote:
>
> That is true when accessing array elements and slices but not for
> indicating the entire array as a single entity such as in a subroutine
> argument, e.g.
>
> y := cos(x);
>
> or
>
> z := x + y;

That's true. I haven't done a lot of code like that recently, so not doing a
renames tends to work fine for me; hence "generally". (Also, I haven't messed
with big arrays much recently, either.) If you do reference the whole array
frequently, it's a different story.

--
Jeff Carter
"I wave my private parts at your aunties."
Monty Python & the Holy Grail
13