[comp.sys.pyramid] More on Pyramid's not so non-standard C compiler

KSpagnol@massey.ac.nz (Ken Spagnolo) (08/04/89)

Oops...  Well, I do feel dumb.  I obviously haven't been keeping up with
what is going into the ANSI standard recently (read last few years). But what
is weird to me is that, from your letters and postings, this way of passing
pointers to structures that I didn't know about (given: struct x x; using
y(&x); instead of y(x);) has been around for quite a while.

I've been programming in C since 1985.  I was taught that structures were
like arrays in that the name of the thing was actually a pointer to the thing.
I have operated under this assumption ever since and have never had a problem!
This includes work done on:  Sun 2/150 and VAX 750 both running 4.2 BSD in
1985 and 1986, VAX 785 running Ultrix 2.? in 1986 and 1987, and a 386 running
Microport's SysV hack in 1988.  I don't know why I never noticed the 'real'
way to do it in any books, other than that I never thought I needed help
with passing pointers to structures and, hence, didn't pay much attention.
I haven't even been able to look this up in my two original C books (K&R and
a blue one by Kochan) because they are on loan at the moment.

When I started working on this Pyramid in January, I was told that it passes
structures differently.  Yes, I'm not the only one!  Two other C programmers
here have had a similar experience to me; one of whom started in C about
a year ago.  And its certainly not because New Zealand is so far from the
rest of the world, because one of us is from Britain and I'm American :-)

I just feel like I've entered the twilight zone.  Thanx for the responses,
both mail and news.  Can anyone explain why I've gotten away with this for
so long?

==============================================================================
Ken Spagnolo - Systems Programmer, Postmaster, Usenet Administrator, etc...
    Computer Centre, Massey University, Palmerston North, New Zealand
K.Spagnolo@massey.ac.nz     Phone: +64-63-69099 x8587     New Zealand = GMT+12
==============================================================================

csg@pyramid.pyramid.com (Carl S. Gutekunst) (08/04/89)

In article <239@massey.ac.nz> K.Spagnolo@massey.ac.nz (Ken Spagnolo) writes:
>When I started working on this Pyramid in January, I was told that it passes
>structures differently.  Yes, I'm not the only one!

Well, it *does* pass them differently -- the Pyramid has two stacks, one a
data stack and the other a register file. In traditional "VAX-like" machines,
you'd pass all variables on the data stack. On the Pyramid, scalars go on the
register file, and structs go on the stack. What this means is the certain
entirely illegal games with parameter passage that "work" on the VAX, 68000,
and 3B2 result in disaster on a Pyramid. And on a SPARC, too for that matter.
Chris Torek gave a good example.

But syntactically and semantically it works exactly like every other machine.

>Can anyone explain why I've gotten away with this for so long?

Sure. If you don't modify the structure, then it doesn't make any difference.

What I am curious about is how you declared your structures in the called
function. There is a big difference between `.' and `->'. By E-mail, though;
we've already cluttered up the net too much.

<csg>