How to convert Infix notation to postfix notation

N

Nick Keighley

Which is interesting.

Because if I wasn't, when I wrote my critique of T:TCR, qualified to write
such a critique, then Spinny *definitely* isn't, at this time, qualified to
write a meta-critique.  So he should withdraw all of his allegations and
claims about flaws in that work, and apologize publically for them!

to be fair again (what again!) he doesn't reject all critcism (though
it sometimes feels like it when he rants about file system design when
someone tells him can't use mixed case in a standard header name).

It is sort of odd.  When people catch flaws in my work, I try to understand
how the flaw arose and deal with not only the flaw, but the mechanism which
allowed it to enter into the code.

ditto. Someone who finds a flaw in your program before it reaches the
real world (or even system test) has done you a favour.

 Even if they're purely stylistic, I
do not like to disregard criticism; it's not sane to do so, because it leads
to worse code.

yes.

Sometimes you have to point out the critic is wrong

if (s != NULL && s[0] != '0')

"might that derefence a null pointer? Perhaps both sides of the and do
get evaluated"
 
N

Nick Keighley

yes there is something: in the Book "Algoritmi in C" by Robert Sedgewick
there is the code that implement it; something like
char  c;
for( stackinit() ; scanf("%1s", &c)!=EOF; )
{if(c==')') printf("%1c", (char) pop());
 if(c=='+') push((int) c);
 if(c=='*') push((int) c);
 while(c>='0' && c<='9')
     {printf("%1c", c); scanf("%1c", &c);}
 if(c!='(') printf(" ");}

I don't think this will work for incompletely parenthasised
expressions. Note the only pop that occurs is when a ')' is
encountered.

consider
2 + 3

I think the '+' gets left on the stack when the loop exits

endL:;
i add the only label endL.

why did you add the label?

this is the point of start for write, modulo errors
on my copy that text
modulo bugs; [don't know if this is a bug
 while(c>='0' && c<='9')
     {printf("%1c", c); scanf("%1c", &c);}
should be
while(c>='0' && c<='9')
     {printf("%1c", c); scanf("%1c", &c);
      if(c==EOF)  goto endL;
     }
]

I don't think that was a bug. Note I'm looking at the Pascal version
of the algorithm so there may be some differences (I doubt it though)
 
P

Phil Carmody

Ben Bacarisse said:
So you read C99 as saying that whether L"abc" is or is not a string
depends on the character set used?

Even if Richard doesn't, I say it does. And if it is a string, that's
purely by coincidence.

A wide string is not (necessarily) a string.

An unsigned long long int is not (necessarily) an int.

In a discussion about apples, whoever introduced L"" started talking
about oranges.

Phil
 
P

Phil Carmody

Rod Pemberton said:
Sorry, not to pick on you Seebs, there probably is much incorrect and
uncorrected stuff in this thread. I've only read a few posts in it.

Your statement is not correct according to the C specifications. It's
correct in practice on machines that support 8-bit bytes as characters.
But, I'm really surprised none of the dominant pedants, er... regulars, here
corrected you... When I imply bytes are 8-bits or should be or one should
learn assembly prior to C, they regularly say to me, "You think: 'All the
world's a VAX/MS-DOS/PC.'" or some such BS.

A string is a contiquous sequence of characters - not bytes as you've
stated - terminated by a "null character" - which is a byte, not a
character.

There are no points in the standard where the substitution of the
complete noun-phrases byte and character for each other would
change the meaning of the clause they're within, except to introduce
tautologies.

[SNIP - Stuff predicated on falsity]

Phil
 
P

Phil Carmody

Morris Keesan said:
That's odd. In the 1970s and 1980s, I used at least 3 different
computer architectures which had bytes with sizes other than 8 bits.
In C, and in "non-C".

And don't forget us DSP users! Maybe we're behind the times as
we were still using them into the 90s and beyond.

(Though the idea of pointers having a smaller range of usable
values than chars is a little worrying, I will admit...)

Phil
 
R

Richard Bos

gwowen said:
I find that rather sad. Personally, I disagree - there remain enough
non-troll non-idiots posting here that in my view the group is still
viable. But it's certainly going downhill.

It would be nice if some of those (presumed) non-troll non-idiots[0]
would find more productive to do than troll-baiting-in-the-name-of-
entertainment, then. Trolls don't spoil newsgroups. Failure to
ignore trolls does.

A-fucking-men.

Richard
 
S

spinoza1111

It is extremely difficult to be good at something while holding it
in contempt.

On the contrary. Uncritical "understanding" is usually superficial
rote learning suitable for clerks, not for free people.
I suspect he knows plenty about them.  There's a big difference between
knowing about something and thinking the entire world is like that.

I'm not saying that the entire world is "like that" any more than Herb
was. You deliberately made a false interpretation to shame a
colleague.

For example, are you even aware that on p 51 of Heinemann, Pollice and
Selkows ALGORITHMS IN A NUTSHELL from O'Reilly, there's a picture of
the stack going "down" in memory and the heap going "up"? And when are
you going to make a fool of yourself by constructing another Vitriolic
Tirade against THIS book?

Your grievous error in interpretation would be like one made by an
autsitic, learning-disordered student who questions, not without some
validity, the fact that in Geography, the Northern Hemisphere is
"above" the Southern Hemisphere, and points out that as seen from
space, the hemispheres could be reversed with respect to the
observer's force of gravity as created by his spacecraft.

I made no progress in learning to write Chinese until I learned that
the strokes MUST be written in a certain order: generally,
horizontals, verticals, and then minor strokes. You neglect that Herb
isn't only telling students "the way the world is", he is also
teaching them "how to" get started and indeed to learn, on their own,
where he was WRONG.

Your autistic insight is that the stack and the heap do not have to
share the same allocated chunk of memory, nor does one have to go up
or down. But in traditional schooling, you'd be beaten for questioning
the model for the same reason Asian students were beaten for not
questioning Western schemata.

Today, both Schildt and Heineman et al. need to make the Platonic idea
concrete because that is the way things are. Nobody can access your
mystical apprehension of the pure abstraction even if you have such a
thing in your mind except by agreement on conventions. You're not
beaten, but that doesn't authorize you to "beat" the teacher.
He is making a point which you are missing.  He has a lot more information

His "point" was farcical. He could see that I had used parameters in a
disciplined fashion, passing them intending them to be read only and
not in fact changing them (there was no point in the code where one of
these values was changed).

Looking for trouble as you were when you wrote The Vicious Tirade, he
probably just ran the gcc compiler with diagnostics set to some
maximal setting in hopes of blindly finding something "wrong" so as to
be able to join, and disrupt, a technical discussion which he isn't
qualified to join...in contrast to many others here, Richard hardly
ever notices an actual bug: instead, he tends to notice, in a debased
and Scholastic way, violations of conventions. Like many people here,
he prefers to laugh at unfamiliar coding styles to actual bug-finding.
That takes work.

Like the idiot he is, he thought he hit pay dirt when his gcc
compiler, with error reporting probably set to a maximal setting threw
out a lot of warnings (not errors) on the parameters, the gcc compiler
detecting that the parameters were read only.

He then "sagely" advised me to be like the mentor he pretends to be to
use const. Anxious to be fair even to Fat Bastard, I tentatively
agreed to use it since it seemed to be a SOMEWHAT useful way of making
the code incrementally better in the next release.

But then a real C expert, a genuine C programmer (Malcolm Mclean)
advised us all that config was a patch.

Referring with a deliberate abstraction to the mistakes of your foes
and the wisdom of your friends has no place here. This thread concerns
different ways to convert infix to Polish notation. You seem to be
helping the guy with an interesting assembler solution I haven't had
time to examine. Please stick to this task.
and experience than that to offer.  By showing only the mechanically-generated
complaints, he's making a significant point -- it is stupid to waste human
engineer time reviewing something when there are problems sufficiently
obvious that a tool can catch them.

The "problem" was that not using const wasn't a "problem", sky pilot.
Right now, in the unrealesed fifth version, I have (1) #defined CONST
to be const and (2) placed it in front of all parameters intended to
be read-only. This way I can compare using it with omitting it.

On the one hand, you and Fat Bastard pretend that C is for rough tough
real programmers who don't need a nanny compiler or safe language to
prevent them from fucking up. On the other hand you advise the use of
patches made to make C safer. This is your libertarian paradox, for
most "libertarians" are in fact control freaks.
Even if this were true, it wouldn't be a compelling argument... But
it's not true.

You can be all macho if you want.  However, "defending" yourself in
the way you do is absolutely rooted in ego -- as is any form of macho
behavior.  Which is to say, fine, you can be all proud of not being
a "soft male".  Me, I'm not going to let whether people think I'm soft
or not keep me from doing the best work I can at a technical level.

Lots of luck with that as a life plan, because at this point, real
"programming" jobs are in fact so "rationalized" as to provide the
techies the illusion that their "skill" makes a difference while
actually enforcing such alienation and so many checks and balances
that it doesn't matter, in most corporate jobs, whether one's a
traditionally skilled programmer.
Which is to say, you can be macho, or you can be a software engineer,
but you can't be both.  Pick one.

I already have. You speak truth occasionally. The fact is that
"software engineers" are software practitioners willing in all cases
to knuckle under any authority no matter how illegitimate who in
return are allowed to fantasize that they have a special "skill", but
who rarely get to exercise the skills of actually creating large
software systems by themselves, a privilege we had prior to 1980. For
this reason, this New Model "software engineer" lives in fear that
what Adorno, again, called "the secret contour" of his social
weakness, his lack of any control over the objective conditions of his
life, and as a result he comes in here, not macho, that would be
refreshing, but as a whining, sniveling bully looking for the
incompetence he fears he manifests.

You get to write tools on the job. Very good. I'm glad you show the
initiative and a modicum of skill. I also crafted a complete compiler
installation toolset at Bell-Northern Research using Rexx, assembler
and PL.I. But my job was making significant modifications to the
compiler based on requests from field engineers who had to use it. The
most significant was rewriting the complete back end to support a new
PBX that unlike the older models had a 24 bit and not a 16 bit word.

Herb has created a complete "tiny C" and works professionally as a
programmer, not a bug checker upper onner, and this meant you had no
standing in writing "C: The Complete Nonsense". Now, this difference
in experience, and in academic certification, would be out the window
had you found a showstopper global bug to his whole approach that
would render the whole book useless.

But YOU DID NOT. You found that specific code examples had bugs in
them, but in general, it is wise for the C programmer to think as if
there's a run time stack folliwing the code in low memory and a heap
in high memory for the SAME reason that all computers are Turing-
equivalent. Even if the programmer is in what you called the "Gettier"
problem space (where I think I saw Madonna in Central Park, but it was
only a life-size cut-out, but in fact she was behind the cut-out) if
he knows the Gettier-problematic metaphor completely and it fits in
all essentials the "real" situations, guess what.

His code works, and Turing discovered that when we compute we can use
what Wittgenstein called (in Tractatus) any old crotchet, any old
conveniences AS LONG AS they constitute the (Wittgensteinian) "great
mirror" of the abstract mathematical reality.

Imagine someone who THINKS he's programming an IBM 1401. He confronts
a 6'*8'*3' blue and grey box and (for convenience of xposition)
programs it using the "customer engineering" panel, throwing switches
and observing lights on the main panel. But one day he opens it to
discover nothing except a motherboard, aan industrial Intel chip
programmed to simulate the 1401.

Is his teacher a fraud? In purely academic terms, yes. But in commerce
and industrial terms the fact is that most people who work in the
corporation are subject to much more serious levels of fraud than the
gentle stories of a Schildt.

You have personalized a more general anger against the failures in
your life in Herb Schildt, and I think you'd be a better person if you
got a real programming job and withdrew "C: The Complete Nonsense".
You might have to work in India to get a genuine programming job: my
last programming job was in China. But do stop taking your
frustrations out on Schildt.
 
S

spinoza1111

In <[email protected]>,

spinoza1111wrote:


(a) I am reasonably sure that I've never claimed to be a C expert, but
feel free to post a message ID to the contrary if you can find one;

Sure, it';s a common managerial mystification to say that one's not an
expert yet to assert the authority over other people and their
reputations of an expert.
(b) a knowledge of Microsoft platforms is not required for C
expertise;

Actually, it is. To claim to know C, an actual in-use product, but not
to know its use on a majority or near-majority of platforms, is
nonsense.
(c) I've programmed for quite a few platforms over the years, and
Microsoft is certainly one of them - I don't know where you got the
idea that I don't know about Microsoft platforms. I don't know
*everything* about Microsoft platforms, but who does?


No, I use compiler diagnostics as a bozo filter. Saves time. If you
can't even get your code to compile relatively cleanly on a fairly

We've found that your const nonsense was a red herring. It's time to
admit that you've wasted our time.
strict implementation, why should I bother to look at it? Others here
have been more tolerant, and that's up to them.





That took you a couple of iterations to get right, and in the meantime

**** you, liar. You pointed out the error and I chose when to fix this
error.
you spouted a lot of nonsense about the fault lying with
case-sensitive file systems rather than with your code. Remember?

No. I said that there were Two Cultures. You failed to understand the
reference to CP Snow.
No, I admit error when I'm *wrong*. It is a practice that I can
commend to you.

**** you Richard Heathfield: **** you very much.
 
B

Ben Bacarisse

Phil Carmody said:
Even if Richard doesn't, I say it does. And if it is a string, that's
purely by coincidence.

A wide string is not (necessarily) a string.

That's fine. I just disagree. It seems to me that the C99 authors
went to some effort to change things so that they can talk about a
terminating null character rather a terminating null byte so it seems
a shame not to take advantage of that and call L"abc" a string. It is
a special kind, but that does not stop it being one.
An unsigned long long int is not (necessarily) an int.

Obviously. But, to take closer example, an extended integer type is
an integer type. C has more than one type of floating point data, and
I think it has more than one type of string.
In a discussion about apples, whoever introduced L"" started talking
about oranges.

That would be absurd wouldn't it? I just started talking about other
varieties of apple.
 
K

Keith Thompson

gwowen said:
I find that rather sad. Personally, I disagree - there remain enough
non-troll non-idiots posting here that in my view the group is still
viable. But it's certainly going downhill.

It would be nice if some of those (presumed) non-troll non-idiots[0]
would find more productive to do than troll-baiting-in-the-name-of-
entertainment, then. Trolls don't spoil newsgroups. Failure to
ignore trolls does.

I agree. If everyone stopped replying to spiniza1111's nonsense, the
signal-to-noise ratio of this newsgroup would rise substantially.
Some of Seebs's replies have been amusing, but enough is enough.
 
S

Seebs

A wide string is not (necessarily) a string.

I am not sure of this.

I think a wide string, viewed as an array of unsigned char, necessarily
contains at least one null byte, therefore, there is a string in it.

I'm not sure whether that's the same thing as "is a string", though.
It is an array of bytes which contains a terminating null byte, though.

-s
 
S

Seebs

I agree. If everyone stopped replying to spiniza1111's nonsense, the
signal-to-noise ratio of this newsgroup would rise substantially.
Some of Seebs's replies have been amusing, but enough is enough.

Yeah, I think at this point I'm convinced that it's simply not *possible*
for him to justify a position.

That said...

I think it was all worth it to get the Stroustrup quote.
In particular, Stroustrup had learned about
object oriented programming using Simula in Denmark before coming to
the US, because in Denmark labor unions had real power and demanded
that factory automation be documented for union oversight.

This will be, for some time, my gold standard example of the non-sequitur,
just as Spinny himself is my gold standard example of the Dunning-Kruger
effect.

Since apart from that, he appears to be a liar, an idiot, probably
insane, and completely incapable of supporting his points, as well as
awe-inspiringly ignorant of C... I'm done with that. Back in the
killfile with him.

.... Which is not to say there will be NO productive output from this. I've
tracked down a used copy of C:TCR 4th Edition, and I'll be updating the
page accordingly. :)

-s
 
P

Phil Carmody

Seebs said:
I am not sure of this.

I think a wide string, viewed as an array of unsigned char, necessarily
contains at least one null byte, therefore, there is a string in it.

I agree with that. Hmmm, unless a wide null character may contain
no null bytes.
I'm not sure whether that's the same thing as "is a string", though.

'Contains' and 'is' I view as being quite different. 'Is' should have
substitutability, IMHO. A string is preserved in value when strcpy-ed,
a string-with-dangling-crap isn't, so a string with dangling-crap is
not substitutable for a string.

I accept that others may have different and valid PoVs in this
regard though.
It is an array of bytes which contains a terminating null byte, though.

Again, no argument.

Phil
 
S

Seebs

That isn't necessarily a good guide, especially as the author has
confessed to writing one of the reviews and may well have written
several.

Wait, you can ...

Just a second, I have to go review my book.

"This is the best book on shell scripting I have ever written."

-s
 
N

Nick Keighley

Nick Keighley said:
this is the point of start for write, modulo errors
on my copy that text
modulo bugs; [don't know if this is a bug
while(c>='0' && c<='9')
{printf("%1c", c); scanf("%1c", &c);}
should be
while(c>='0' && c<='9')
{printf("%1c", c); scanf("%1c", &c);
if(c==EOF) goto endL;
}
]
I don't think that was a bug. Note I'm looking at the Pascal version
of the algorithm so there may be some differences (I doubt it though)

is it possible that the first EOF not close the stdin FILE*?

EOF never closes a file
 
K

Kenny McCormack

If the statement by Seebs is wrong, I'm very curious what your
definition of "computer" is.

I was going to give a long detailed explanation, but then I realized
that if you claim to believe this twaddle, there's no hope for you.

In the process of thinking about this, I realized how right Nilges is
when he uses the word "Shibboleth" to describe the workings of this
group. There is a series of stupid and insane things that one has to
profess to believe in order to be accepted in the in-crowd here. And
one of them is that a toaster is a computer.

See also: canard.
 

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,811
Messages
2,569,693
Members
45,473
Latest member
Leanne70L5

Latest Threads

Top