subroutine stack and C machine model

S

Seebs

Ah, now this is interesting. I'd like to know in what you believe that
the C for-loop doesn't follow the Fortran model, and why you think this
is a mistake.

I believe, though I never actually did much with FORTRAN, that its for
loops were completely determined when first encountered. You couldn't
specify arbitrary conditions, nor could the internals of the loop affect
the iterator.

As to whether C's for loop is a mistake:

for (l = head; l; l = l->next) {
}

Seems to me that this is a very GOOD for loop.

At this point, I think we've established that Spinny:
* Doesn't know C particularly well.
* Hates C.
* Doesn't know anything about Schildt's books.
* Considers Schildt's books to be amazingly excellent.
* And yet, disagrees with some of the material in them.

In short: We can confidently assert that we are not dealing with a sane
objection. At any level. He's clearly not competent to have an opinion
on the quality of the book he's so vehemently defending, it's not at all
obvious that he's qualified to have an opinion on C in general, and his
positions have attained a sort of surreal level of incoherence we rarely
see.

-s
 
S

Seebs

In
<485fc03a-6ef0-4fdb-a955-c45c28e486b2@y32g2000prd.googlegroups.com>,
spinoza1111 wrote:
I disagree. But why do you think so? What benefit would it confer that
makes up for the additional complexity and reduced efficiency of
implementations?

You could ask Spinny, who's never been able to answer direct questions
on issues like this (or at least, never able to do so coherently), or
you could look at the Java rationale.
No, it didn't do so because it's not necessary.

I should point out that the decisions in question were made LONG before
I was involved with C standardization, or indeed, with C in any form.
He didn't? So you are now claiming that Seebs *did* take a compiler
development class?

I think he's claiming that I got involved with stuff I didn't understand.
(Which is arguably true, and one of the reasons I listened more than I
talked at most C meetings.) But your point stands -- Spinny's claims
about what I would have learned from a compiler development class appear
to refer specifically to a spectacularly bad compiler development class
in which the course material is full of errors.

.... Not to say that I can rule out the possibility that such exist. :)

-s
 
B

Ben Bacarisse

Seebs said:
Not quite. Rather, I believe that, if you follow the syntax down far
enough, you can tell them apart, because constant values can be distinguished
from variables.

Well, to my mind, if you keep enough of the parse tree you can
distinguish a volatile qualified object from a non-qualified one which
was your canonical non-syntactic distinction.
Could be. In which case, the claim that you can tell whether or not
something could have side effects by looking at the syntax becomes
essentially useless.

It just means there is more to discuss -- for example, pinning down
some terms before moving on. What matters to a compiler is what can
be determined from the information it has, and that is clearly more
than what you choose to call syntax. I don't mind if you want to use
a very narrow meaning, and you should not object to my using a
slightly wider one. We may even have to agree on one for convenience,
but the terms we use have no effect on what can and can not be
determined about a C program.
 
S

Seebs

Well, to my mind, if you keep enough of the parse tree you can
distinguish a volatile qualified object from a non-qualified one which
was your canonical non-syntactic distinction.

I'm just looking at the parsing of a single expression. If you know
that a given unary-expression has at its root an integer constant, then
you know that the expression is a constant. On the other hand, there
are some things you can't tell apart -- as someone helpfully pointed
out (Keith, maybe?), you can't tell an enum value from a variable
syntactically.
It just means there is more to discuss -- for example, pinning down
some terms before moving on. What matters to a compiler is what can
be determined from the information it has, and that is clearly more
than what you choose to call syntax. I don't mind if you want to use
a very narrow meaning, and you should not object to my using a
slightly wider one. We may even have to agree on one for convenience,
but the terms we use have no effect on what can and can not be
determined about a C program.

But they have a great deal of effect on the question of what can be
determined about it *solely from its syntax*. Static analysis can do
amazing things -- e.g., lclint used to use a garbage collector, but they
did some static analysis on it and fixed all the memory leaks, so now it
doesn't need one. There exist large sets of programs for which you
can, statically, determine whether or not they can ever leak memory.

I think, to bring it vaguely back into context, the question was in the
context of whether a compiler could tell whether a given optimization would
be safe. For instance, if you have two functions which print output, and
you add their return values, can the compiler reasonably tell that their
order of execution matters? I think the general answer is probably "it's
not reasonable to expect compilers to know."

-s
 
S

spinoza1111

You could ask Spinny, who's never been able to answer direct questions
on issues like this (or at least, never able to do so coherently), or
you could look at the Java rationale.

My name isn't spinny.

I don't think you understand "the Java rationale", otherwise you'd
take the risk of explaining it. However, I think you cover up your
ignorance with phrases like "you could look it up" and when that
doesn't work, trashing other people.
I should point out that the decisions in question were made LONG before
I was involved with C standardization, or indeed, with C in any form.


I think he's claiming that I got involved with stuff I didn't understand.
(Which is arguably true, and one of the reasons I listened more than I
talked at most C meetings.)  But your point stands -- Spinny's claims
about what I would have learned from a compiler development class appear
to refer specifically to a spectacularly bad compiler development class
in which the course material is full of errors.

Explain what justification you have for making this statement. You
see, you've said that you've never attended a CS class. Nor does what
you've done on the C99 effort, nor said here, show that you even
understand compiler optimization theory that recognizes that SOME
expressions can be reordered but that it's untrue that ANY can be
safely reordered. Because of this, you made an even bigger error, it
now appears to me. You made an unsafe language more unsafe than it was
already, by putting the onus on thousands of C programmers to figure
it all out, while conducting a campaign of personal destruction
against a computer author who was trying to make sense of the mess you
made.

You appear to have used a superficial knowledge of compiler
optimization to infer, incorrectly in light of Aho/Sethi/Ullman, that
ALL constructs can or should be reorderable in a way that violates and
insults the intelligence of the ordinary programmer even more so than
K & R C, because by your own admission you did not then (and may not
now) know what you were doing.

Were you aware in 1999 that some constructs can be safely reorderable
given dataflow analysis, and others not? Or did you participate in a
standard that made large classes of unsafe constructs reorderable not
knowing anything about the ability, then and now, of optimizing
compilers to identify safely reorderable code?

Did vendor salesmen, in fact, convince you that according to their
compiler experts, no constraint could be placed on reordering that
might not break their compilers although it was known at the time how
to do this? At this point, it appears to me that owing to your lack of
education, and mental laziness, you made a serious error.

You appear not to have read the literature in lieu of taking the class
since you worked on a standard in which this distinction is not as far
as I can see made. You have stated that you acted fraudulently since
we need people with qualifications and understanding to standardize
programming languages.

Please identify at least seven books on computer science you have
read, right here. Also, I need to know what you majored in and whether
you received an undergraduate or graduate degree, in what major, and
from what institution.

Reading alone would not make you a collegial person educated in
computer science, for you share with Richard Heathfield the ignorant
school-leaver's penchant for transforming ideas into personalities,
and spreading lies in lieu of being qualified to discuss ideas. In
fact, when you encounter prose beyond a certain level of complexity
that is nonetheless grammatical but not from a person with power over
you you mock that prose like a high school dropout. Are you a high
school dropout?

What, in short, were your qualifications for pulling your stunt "C:
The Complete Nonsense?" What, in short, were your qualifications for
being a member of the C99 standard effort?
 
C

Chris McDonald

spinoza1111 said:
Along with the ability to spell, experience in using multiple C
compilers to support the work of a Nobelist, the completion (with an A
+ average) of most of the work towards MSCS in computer science, and
the completion of the first class in comp sci offered at my
undergraduate institution.


So, you've no greater qualifications than many people posting here?
Moreover, you certainly possess no greater credibility (happy that there's
no typo in there, this time?) simply because you helped someone who,
independently of and probably despite your help, achieved great success.

You cling to your chance encounters with Nash like shit to a nappy;
no-one here is fooled into believing that you are a better programmer,
certainly not a better C programmer, because of it.
Are you hoping to embarrass Nash's family?
 
T

Tim Streater

Seebs said:
I believe, though I never actually did much with FORTRAN, that its for
loops were completely determined when first encountered. You couldn't
specify arbitrary conditions, nor could the internals of the loop affect
the iterator.

I haven't written Fortran since 1978, but as I recall it was limited to
integer counters, and could count up or down, and your loop was
essentially like:

DO 10 I = J, K, L
.... code ...
10 CONTINUE

where I was the loop variable, and J, K, L were initial, final, and step
values in some order I've forgotten (J, K, and L were allowed to be
variables or constants, but I can't remember if expressions were
allowed). The label was on the final statement but I always put it on a
CONTINUE (a NOOP) to assist possible later editing. The main drawback of
this (very limited) loop structure was to my mind that even if the
termination condition was satisfied at entry to the loop, the loop was
executed at least once.

I'm curious know what Mr Nilges meant with his comment above.
 
S

Seebs

So, you've no greater qualifications than many people posting here?

Experience using multiple C compilers isn't a particularly great
qualification. I'd be more interested in questions like whether he'd
successfully identified bugs in them, or fixed bugs in them, or
anything like that... Anyone can use several C compilers.

(And most people who have used multiple C compilers wouldn't think that
compilers in general used to consistently enforce left-to-right evaluation...)
You cling to your chance encounters with Nash like shit to a nappy;
no-one here is fooled into believing that you are a better programmer,
certainly not a better C programmer, because of it.
Are you hoping to embarrass Nash's family?

I suspect it's all status to him. He wants people to agree with him, so
he tries to tell people how important he is, because that's how agreement
happens in his world. The idea that there would be a logical connection
between arguments presented and conclusions accepted might be a bit foreign.

-s
 
P

Phil Carmody

Richard Heathfield said:
In
<cf51b708-1bfb-4f35-b389-a25fee112120@t11g2000prh.googlegroups.com>,
spinoza1111 wrote:



Interesting take on informed technical discussion.

<more nonsense snipped>

I was going to criticise you for continuing to repeatedly feed
the trolloon, but if he's going to implode/explode so publicly
then I'll go fetch my marshmallows and umbrella, so I'm prepared
for both possible outcomes.

Phil
 
P

Phil Carmody

Richard Heathfield said:
In


No, it uses sequence points (I know you don't know what they are, but
bear with me here) to specify evaluation order precisely.

A sequence point is a point in the code at which all prior evaluations
and side effects have taken place (or at least a strictly conforming
program can't tell that they haven't), and no subsequent evaluations
or side effects have yet taken place (parenthetical ditto).

Thus, in the code:

a=b; c=a;

the introduction of a sequence point after the first assignment
guarantees that the assignment of b's value to a is complete before
the next assignment begins (or at least that a strictly conforming
program won't be able to tell if it isn't).


And, like all your cheap shots, it was over-priced.

And aimed at his own foot!
Several errors here. Firstly, they're called "sequence points", not
"sync points". Secondly, you claim knowledge of the identity of their
inventor but it's fairly obvious that you don't have that knowledge.
Thirdly, your reference to "unqualified people" is clearly a

troll.

You bit.

Phil
 
P

Phil Carmody

Gareth Owen said:
Nilges,

You are an unpleasant misanthrope,
and a really truly terrible prose stylist.

Enjoy your unemployment.

I'm pretty sure this is a full time jobbie for him.

Phil
 
S

Seebs


Probably not. Do a bit of background reading. Some guy got laid off or
something and his defense against thinking it's actually in some way related
to his ability as a programmer is to invent an amazing conspiracy in which
the entire purpose of C standardization is to justify firing compiler
developers, which is why the language leaves things unspecified or undefined,
and a big part of that is the sinister campaign of people who actually
sort of like the standard to discredit Schildt, who has become a sort
of talisman of what life was like when coders were big red-blooded guys
in lumberjack shirts who didn't waste their time talking to ivory tower
intellectuals.

It's got the sort of "logic" that marks that sort of delusion, and a lot of
it is really too sad to be funny. I don't think it's intentional trolling.
(And if it is, then this is the one Kibo told us would come.)

-s
 
S

spinoza1111

I haven't written Fortran since 1978, but as I recall it was limited to
integer counters, and could count up or down, and your loop was
essentially like:

DO 10 I = J, K, L
... code ...
10 CONTINUE

where I was the loop variable, and J, K, L were initial, final, and step
values in some order I've forgotten (J, K, and L were allowed to be
variables or constants, but I can't remember if expressions were
allowed). The label was on the final statement but I always put it on  a
CONTINUE (a NOOP) to assist possible later editing. The main drawback of
this (very limited) loop structure was to my mind that even if the
termination condition was satisfied at entry to the loop, the loop was
executed at least once.

I'm curious know what Mr Nilges meant with his comment above.

The semantics of Fortran loops varied for different compilers but for
the most part the iteration limit was copied to a register and thus
unaffected if the variable was modified in the loop. C's for loop
allows the limit to be recalculated inside the loop and this is a
source of bugs for two reasons. The first reason is its difference,
not only from most Fortran but also from most other languages and
their for loops. The second is that it makes the loop less verifiable.
And it was an indication of the amateurishness of C's developers that
the issue doesn't seem to have been seriously considered when C was
being developed. It probably merely seemed more "powerful" to have the
"dynamic" as opposed to "static" for, because elsewhere we see that
C's developers and fans systematically confuse a large set of
permitted programs, 99% of which are disasters waiting to happen, with
their personal power.
 
S

spinoza1111

Probably not.  Do a bit of background reading.  Some guy got laid off or

"Some guy got laid off or something" as a serious response reminds me
very much of William Butler Yeats poem, The Stare's Nest in My Window,
written during the Irish troubles about people who preferred
personality destruction (leading to physical assassination), to civil
discussion.

Here is the poem.

The bees build in the crevices
Of loosening masonry, and there
The mother birds bring grubs and flies.
My wall is loosening; honey-bees,
Come build in the empty house of the stare.

We are closed in, and the key is turned
On our uncertainty; somewhere
A man is killed, or a house burned.
Yet no clear fact to be discerned:
Come build in the empty house of the stare.

A barricade of stone or of wood;
Some fourteen days of civil war:
Last night they trundled down the road
That dead young soldier in his blood:
Come build in the empty house of the stare.

We had fed the heart on fantasies,
The heart's grown brutal from the fare,
More substance in our enmities
Than in our love; O honey-bees,
Come build in the empty house of the stare.

"No clear fact to be discerned", just claims based on initial
propositions of the form "So and so is incompetent".
something and his defense against thinking it's actually in some way related
to his ability as a programmer is to invent an amazing conspiracy in which
the entire purpose of C standardization is to justify firing compiler
developers, which is why the language leaves things unspecified or undefined,
and a big part of that is the sinister campaign of people who actually
sort of like the standard to discredit Schildt, who has become a sort
of talisman of what life was like when coders were big red-blooded guys
in lumberjack shirts who didn't waste their time talking to ivory tower
intellectuals.

Huh? You don't have my talent for reconciling metaphor and logic at
all, so I'd avoid using the Lumberjack Song here. The problem is that
you're not an "ivory tower intellectual" in any real sense and you're
proud of it: you haven't taken a single computer science class and yet
you propose to sit on judgement of people who have.

The only real sense in which you are an "ivory tower intellectual" is
that vendors and business cases control new development, and because
during the Bush and Clinton administrations, the takeover of the
public interest for private gain emptied the "ivory tower" of a
previous generation and installed people who are "ivory tower
intellectuals" only in the sense that they can live in ivory towers
only insofar as they justify corporate profit-taking. Their "ivory
tower" is Yeat's empty house of the stare.

Like the Nazis who replaced Husserl as rector of the university of
Freiburg with Heidegger, you have transformed a previous generation of
ivory tower intellectuals into dancing trolls outside the gate because
in your case and others, the barbarians are inside the gates.

Yes, Peter, like the Nazis. Godwin==1.
 
S

spinoza1111

How is it "informed"? Heathfield's Fourteen Errors manifested
ignorance of a basic programming law which is to delay "efficiency"
until there is understanding, because instead of listening to the
point being made at the time (OO encapsulation) he went off like a
crazy person on a tangent on my ability to speak based on a few
microseconds. Peter Seebach is proud not to have taken a single
computer science class and apparently as a result, the C99 standard
did not distinguish between code that can be known to be
resequenceable and code that cannot be known as such.

"Oh **** you" was preceded by poetry and followed by a quote by Oliver
Cromwell because it's clear to me that Seebach and Heathfield are
corrupt and cannot themselves be persuaded at this time. They won't be
convinced by rational argumentation because they assume that they are
rational 24/7 despite the fact that it's not rational at all to base a
case against an idea on the assumed defects of its originator,
especially when the defects of the originator are proved by means of
circular logic which begs the question.
 
P

Phil Carmody

Seebs said:
Probably not. Do a bit of background reading. Some guy got laid off or
something and his defense against thinking it's actually in some way related
to his ability as a programmer is to invent an amazing conspiracy in which
the entire purpose of C standardization is to justify firing compiler
developers, which is why the language leaves things unspecified or undefined,
and a big part of that is the sinister campaign of people who actually
sort of like the standard to discredit Schildt, who has become a sort
of talisman of what life was like when coders were big red-blooded guys
in lumberjack shirts who didn't waste their time talking to ivory tower
intellectuals.

It's got the sort of "logic" that marks that sort of delusion, and a lot of
it is really too sad to be funny. I don't think it's intentional trolling.
(And if it is, then this is the one Kibo told us would come.)

He certainly posts in order to get responses, and he certainly repeats
key words or phrases in order to guarantee that. (The density of which
I don't know, but those who more liberally snip in their responses to
him definitely draw attention to those parts.)

But don't for one minute think that I don't recognise him as a loon as
well as an occasional troll.

Phil
 
T

Tim Streater

Y'know chaps, I'm not sure we ought to be doing this. It's too much
like, as they did in the 18th Century, visiting Bedlam and poking the
inmates with sticks.
 
T

Tim Streater

spinoza1111 said:
The semantics of Fortran loops varied for different compilers but for
the most part the iteration limit was copied to a register and thus
unaffected if the variable was modified in the loop.

Attempting to look this up, now, I discover that lots of FORTRAN doccy
seems to just say "modifying the loop counter is banned" or "would cause
great confusion" or similar

You appear to be saying that, sometimes you can, sometimes you can't.
Not a satisfactory state of affairs.
C's for loop
allows the limit to be recalculated inside the loop and this is a
source of bugs for two reasons. The first reason is its difference,
not only from most Fortran but also from most other languages and
their for loops.

Well, personally I use PHP and JavaScript, both of which follow the C
model.
The second is that it makes the loop less verifiable.

Verifiable by whom or what? I tend to verify my own code.
And it was an indication of the amateurishness of C's developers that
the issue doesn't seem to have been seriously considered when C was
being developed. It probably merely seemed more "powerful" to have the
"dynamic" as opposed to "static" for, ...

Zzzz zzzz - zonk!

(Cue snores of boredom)

Oh! Has he stopped babbling now? Right. It certainly is more useful to
be able to modify the loop counters and it's well defined what happens,
unlike, as you say yourself, with FORTRAN (at least, up until I stopped
using it).

When writing C, you just have to learn to take care, is all, just as
with any program. The only sizeable bit of C I wrote (some 30k lines)
ran on a MicroVAX and used to run for 9 months at a time with no extra
page faults, no intervention, and no restarts. Why 9 months? Because of
the annual site-wide power outage for maintenance of the 240kV line that
supplied power to the site. So, writing reliable code with lots of
malloc() and free() usage is quite possible.
 
N

Nick Keighley

"Nick Keighley" <[email protected]> ha scritto nel messaggio

it's a really good way to teach C as it's actually true. I once wanted
to call a function like this
    f (a, a + 1, a + 2);

but I coded it
   f (a, ++a, ++a);

the compiler wasn't as mean to me as it could have been (those ++
operators result in undefined bahaviour) but it actually evaluated the
arguments right to left rather than left to right. So *don't* assume
arguments are evaluated in any particular order.

<so why all compiler can evalue that in no order particular
<and not left to right?

If you meant "why don't all compilers evaluate left to right?" the the
short answer (for C) is functions with variable number sof parameters.
Consider:-

void print (int count, ...);

where the count is followed by the specified number of strings (I'm
not claimign thsi is a good design).

print (2, "red", "blue");

On a typical system the stack on entry to the function looks like this

<-- SP
<ret addr>
2
"red"
"blue"

No matter how many strings there are the count is always at the top of
the stack, making it easy to find. The first C compilers ased a stack
like this and the caller cleaned up the stack after the call (only the
caller knew how many items were on the stack). For efficiency reasons
Microsoft allowed you specify (with a non-standard extension) that a
function used "pascal" calling convention (even in a C program). These
evaluated arguments left to right and the called-function did the
stack cleanup. These functions couldn't use varargs arguments.

<there is some gain to do that; how many cpu cicles to gain?
<where is the advantage?
<there are theoretical problems?

<the gain for to choose a way [left to right or right to left]
<is to delete the UBs that are with that "no order particular"

giving the compiler the freedom to rearrange arguments could help
optimising compilers (though I think Jave and C# consider it better on
balance to specify the order of evaluation).

<"f (a, ++a, ++a);"
<not will have UB

Yes it will, it's modifying a more than once between sequence points.

is you whitespace key borken. I've edited your code to make it
readable
a = a + (++a + c) + a++;

this is undefined behaviour. Even this is

a = ++a;
"a = (++a, a + (a + c) + a); ++a;"

a string doesn't have UB

a = 1;   c = 1; a = 2 + (2 + 1) + 2 at end a = 8

=> a = a + 7;

there is no UB.
there will be UB too?

no, why?
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top