No machine stack and C

D

Dik T. Winter

> Perhaps he was thinking of phony C compilers from fraudulent vendors.
> Or, implementations of brain-damaged subsets of C for limited embedded
> platforms where the user didn't need recursive procedures.

Did you miss my article where I wrote that van Wijngaarden had proved that
all programs containing procedures could be re-written in programs without
procedures?
 
S

Seebs

AFAIK I never read one of Schildt's books so I can't comment on
their quality. However if I were writing a book I would be chary
about talking about "the stack". Given the duality of usage of
the term, doing so is likely to be a source of confusion.

Schildt's books unambiguously and clearly describe the hardware
feature and state that it is *the* way in which C handles things such
as function arguments and local variables.

-s
 
S

Seebs

I have a counter-example, already cited elsethread: C:TCR2, p719 -
"Like most C compilers, Microsoft C passes arguments to functions on
the stack." "Most" implies "not all".

This is presumably in the section on interfacing to assembly routines,
which covers similar content:

"Virtually all C compilers use the stack to pass arguments to
functions."

(C:TCR3, p.693. I don't think I'd buy "virtually all". I'm not
even sure about "most".)

But he also, in the initial explanation, simply says that:

"[The stack] holds the return addresses of function calls, arguments
to functions, and local variables."

So there's some difference here. Only programmers planning to write
assembly routines and interface with them would find the more nuanced
explanation; programmers not planning to work at that level get told
wrong -- and it's programmers not planning to work at that level who have
the least reason to hear the word "stack", because it's not relevant
to what they're doing.

-s
 
K

Keith Thompson

Richard Heathfield said:
I have a counter-example, already cited elsethread: C:TCR2, p719 -
"Like most C compilers, Microsoft C passes arguments to functions on
the stack." "Most" implies "not all".

I think Schildt assumes (wrongly, of course) that there must be a
contiguous hardware stack, but arguments may sometimes be passed
by other methods.

A system on which, say, the first N arguments are passed in
registers, but excess arguments and local variables are always
stored on "the stack", would be consistent with Schildt's model,
though it sounds like he'd see it as unusual. A system on which
the activation record for each function call is allocated in a
malloc-like manner would not, though it would be entirely consistent
with the C standard.
 
S

spinoza1111

Well, no, he's both right and wrong, depending on what
definitions one uses.  The function call/return mechanism in C
has properties of the abstract data structure called a stack.
This is true whether or not recursion is used. I hope we can all
agree on that.

There also is an architectural feature called a stack.  This is a
contiguous area of storage with a pointer into it.  It is used as

No, a stack is no such thing. It is an abstraction (T,S,R) where T is
a read write top, and a member of the set S (of which T is a member)
which has a successor rule or mechanism R that is known to exist but
about which we know nothing.

Alternatively take out R and change S from an unordered set to an
ordered n-tuple.

Contiguity be damned.

This is the Platonic Idea, and Herb's picture was the Aristotelean
model.

Schildt writes at the level of working people on whom programming
languages are more or less imposed and who cannot question work rules.
He gives no evidence of belief that a stack must have any one specific
layout as long as it meets the above abstract definition, whereas
highly educated people here (in the sense of certification) give
evidence of misunderstanding or dishonesty, because they present all
sorts of claptrap which turn out to support the above model.

Their fear is of contamination by hordes of ignorant Sophists in the
form of Microsoft programmers, who they imagine to be intrinsically
less educable than they.

There is a truth in this view. I've known people with 20 years of
experience of being intellectually brutalized in Microsoft "shops" who
don't know whether the right hand side of the Or in their language is
evaluated, or what (as we say in Chicago).

But (as Shakespeare knew) there is a Higher Brutalization.

Shakespeare, in Julius Caesar, shows a character, Brutus (where the
name was psychologically apt but not devised by Shakespeare) who
despite his "nobility" is a common thug. This was because Shakespeare
saw what happened to Marlowe, a scholarship student at Cambridge
(Corpus Christi).

Marlowe's education, as described by David Riggs in "The World of
Christopher Marlowe" was so competitive for scholarship students that
it soured Marlowe's personality and made him a thug as well as a
poet...whereas Shakespeare, with some life experience before coming to
London, was unique among playwrights known to us of his time:
Shakespeare was never busted for fighting.

In computer science, the Higher Brutalization is the fact that
computer science never solved the correctness problem, but instead
turned aside to make essentially incorrect software run fast in what
was essentially a boy's game. But Schildt's audience isn't interested
in high speed for its own sake: it wants to make its software work,
even as Shakespeare, rather than showing off how educated he was by
using too many Latin tags, wanted to make plays that could be staged.
a stack thusly:  Items are pushed onto the stack by copying them
into the region beginning at the current stack pointer, followed
by moving the stack pointer.  Items are popped by moving the
stack pointer to the beginning of where the item was loaded.  (I
assume that everybody knows this but it's worth making sure that
we are all on the same page.)

Back in the early days people realized that hardware stacks
provided a simple and efficient way to implement function
call/return.  Is it the only way to implement call/return.  No.
In some circumstances it may not even be the most efficient way,
either for space or time.

Equivocation. Nobody here is saying that hardware stacks are needed to
run C.
The confusion begins when people jump back and forth between the
two concepts.  Nilges has done this regularly, but he is scarcely
the only one.

No, I have nailed myself to the mast. A stack is an abstraction which
is best spoken of in words if you're teaching a data structures class,
since it IS possible that Little Darlings in data stuctures class
might confuse it as you do. Working people reading a computer book on
the other hand are in most cases able to distinguish a model from
reality, because they are lied to so regularly.
The other side of the coin is the insistence by some that "stack"
means an architectural feature.

AFAIK I never read one of Schildt's books so I can't comment on
their quality.  However if I were writing a book I would be chary
about talking about "the stack".  Given the duality of usage of
the term, doing so is likely to be a source of confusion.

Please don't write a book, then. Lemme tell you, it won't make you
rich.
 
S

spinoza1111

I have a counter-example, already cited elsethread: C:TCR2, p719 -
"Like most C compilers, Microsoft C passes arguments to functions on
the stack." "Most" implies "not all".

So what do you say that Herb says?

Some of you (such as Seebach) say he says that we need a hardware
stack (although he doesn't).

You use his use of "most" to show that he does NOT believe that "a
stack" is always necessary.

Of course, if the game is "get Schildt", you'll say anything.
 
S

spinoza1111

I have a counter-example, already cited elsethread: C:TCR2, p719 -
"Like most C compilers, Microsoft C passes arguments to functions on
the stack." "Most" implies "not all".

This is presumably in the section on interfacing to assembly routines,
which covers similar content:

        "Virtually all C compilers use the stack to pass arguments to
        functions."

(C:TCR3, p.693.  I don't think I'd buy "virtually all".  I'm not
even sure about "most".)

But he also, in the initial explanation, simply says that:

        "[The stack] holds the return addresses of function calls, arguments
        to functions, and local variables."

So there's some difference here.  Only programmers planning to write
assembly routines and interface with them would find the more nuanced
explanation; programmers not planning to work at that level get told
wrong -- and it's programmers not planning to work at that level who have
the least reason to hear the word "stack", because it's not relevant
to what they're doing.
Write when you and Heathfield get your story straight, Peter.

You have arrived at a point where you divide programmers into two
sharply divided classes.

On the one hand, we have students who went to "good" schools: who
didn't have to serve in Iraq or Afghanistan to get the money. They are
tracked into high-tech applications where they may even need to write
critical code in assembler.

On the other hand, we have students who are tracked into writing, or
more often maintaining, C code written typically for financial
applications. You don't want them to be told about the stack.

This is like the "university wit" Marlowe telling Shakespeare to write
the boring part of the First Part of the Contention (between York and
Lancaster): the lines for women characters, probably...and discovering
that Shakespeare's lines for Queen Margaret and Humphrey's wife
brought down the house.

To believe as did Plato that working people will misunderstand an
idealized model is Fascistic. The fact is, Peter, that working people
developed the stack even as Euclid stole his math from praxis. In
1955, there was no "computer science": but in my lifetime, I have seen
the creativity in the papers of Saul Rosen's 1968 book "Programming
Systems and Languages" transformed into secrets, coupled with vicious
attacks on people who like Herb go against the flow.
 
S

spinoza1111

Dear child, a word may have more than one meaning.  I know this
will come as a shock to you but there it is.  Do have a good day.

It appears to me that when it's convenient to winning an argument,
dictionaries are hurled and words have definite meanings: but when
it's convenient, to winning an argument, that words have more than one
meaning, they do, and it also becomes justifiable to use contemptuous
forms of address, while of course banning vigor of verbal self-
defense. For example, Derrida was astonished at the childishness of
his opponents, especially at Oxford. It is childish to write "dear
child".

Had it been necessary for the anti-Schildt people here to insist that
a word have one meaning, then of course, they would have. But here,
their task is to show us that (contrary to common educational practice
in compsci world wide) the stack isn't a tool for understanding.

I have pointed out before that elites (from Romans of the late Empire
who didn't want to pay taxes and caused the fall of Rome thereby to
American bankers of today) will Samson-like bring down civilization
rather than give up their privilege, an idea expressed by the Polish
marxist Rosa Luxemburg in her phrase "socialism or barbarism". The
stack civilized programming because it's the simplest way of enabling
subroutine call including recursion. Stackless environments (such as
the world of Cobol programming in the 1970s) were barbaric: I noticed
at Bell Northern Research in 1981 that the use of the stack in the
architecture of the SL-1 digital switch civilized the developers, who
treated each other with dignity, collegiality and respect because
their jobs were doable, and continued to do so until the evolution of
the SL-1 was destroyed by Northern Telecom executives.

Here, you're trying to destroy Herb's ability to write sensibly about
how we can evaluate expressions with function calls, parentheses, and
operator precedence.

I am well aware that words have multiple meanings: more than once my
arguments have turned upon this point. This is why we have
mathematical language in which ordinary words, ordinarily with
multiple meanings, are arranged in structures in which they have a
fixed, if minimal meaning.
 
S

spinoza1111

In <[email protected]>,





spinoza1111wrote:


See above, where I quote him directly. Alternatively, see



The game is not "get Schildt". The game is "get the truth". The truth
is that Schildt makes it quite clear that a stack is not required for
parameter-passing, but that it is very common. And, funnily enough,
he's right. I don't see how my pointing out that he's right can be
constituted as "get Schildt".

I find it a little odd that, on one of the few occasions he actually
gets something right that he might reasonably have been expected to
get wrong, you end up disagreeing with him.

Then again, perhaps it's not so odd after all.

You were proven wrong, and like too many corporate sleazebags I've
known, you create confusion in response.

You took one word, "most", and you discovered (yesterday) that Schildt
did not do as he was charged by Seebach and Feather. Instead of
posting an apology to Schildt and a condemnation of Seebach and
Feather, which would carry some authority given your status with some,
you create a silly difference between Schildt and I.

Schildt probably used "most" because he's not telling compiler and
runtime authors their business, and like you may have, fifteen years
ago, believed that perhaps there might be a better way to do runtimes.
We now know that the stack is mathematically minimal: I believe
Smorgrav unintentionally showed this since his queue and cache are
mathematically nothing of the sort.

You need to post an apology to Schildt, an apology to me, and then you
need to go to Spain and get drunk, and stay off the Internet. Then you
need to learn more about compsci.
 
S

spinoza1111

On Sun, 13 Sep 2009 00:49:24 -0700 (PDT),spinoza1111


[Snip text wherein, having been caught with his hand in the
cookie jar, Nilges boldly denies that it wasn't there, that there
were no cookies in the cookie jar, and that there never was a
cookie jar, and besides everything is a part of a conspiracy on
the part of American Bankers and ribbon clerks disguised as
programmers to trash that noblest Roman of them all, Herb
Schildt.]

Well done sir.  I have a fondness for you.  Granted you have
anger management issues, inordinate ego inflation proclivities,
and that you reflexively regurgitate leftist academic agitprop.
Still, amidst all the flapdoodle and ass covering is much of
interest.

Richard Harter, [email protected]://home.tiac.net/~cri,http://www.varinoma.com
Kafka wasn't an author;
Kafka was a prophet!

Excuse me, Mr. Harter, but this is more than "damning by faint
praise". It is schizophrenic, although not in the medical sense, in
the sense of split personality. Basically, you're too much the coward
NOT to add to the libel although you recognize the worth of what I
have said, and I shall expect from you an apology.

In other words, until like a man you disassociate yourself from the
vicious children here, you can take your faint praise, and shove it up
your ass.
 
S

Seebs

ROTFL - if you correct the guy, you're libelling him. And now, it
seems, if you *don't* correct him, you're a coward.

*sigh*

Why can't we just have it both ways?

-s
 
F

Flash Gordon

Seebs said:
*sigh*

Why can't we just have it both ways?

I'm sure you can. If you try I'm sure you can be labeled as a coward
*and* accused of libelling him!
 
D

Dik T. Winter

> We're not arguing about the essential nature of the Scotsman, nor of
> the Dutchman for that matter: do you really want to get me started on
> that subject Mijn Heer?

Why do you write to Dutchmen as if they are deities?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,799
Latest member
Mercury_Dev

Latest Threads

Top