How to convert Infix notation to postfix notation

S

Seebs

trim your posts?

He can't.
although this is a bit of a angels on the head of a pin discussion
Agreed.

Peter Seebach /is/ correct here. When I read Spinoza's code I was
expecting -1 to be a failure indication. Idioms and cultural norms are
important.

That was the point, really. All the arguments about what true should or
shouldn't be are sort of arbitrary, although there's a lot to be said for
accepting the value the language provides for !0. But once people have
picked an answer, sticking with it is important.

Whether it's better to drive on the left or right side of the road appears
to be very close to a moot point; there's no obvious reason to assert that
either answer is unambiguously superior. But, once you know that you are
in a place where a particular answer has been adopted, it's crucial to
acknowledge that they've picked an answer.

-s
 
K

Kenny McCormack

But if they have CPUs, they're still computers. We target a lot of those
things with C compilers.

Wrong (of course - could it ever be otherwise with you?)

.... If it has wheels and an engine, it is a car ...
 
S

Seebs


So you say, but you don't really argue it.
(of course - could it ever be otherwise with you?)

Wow, you're still pretty butthurt about having the emptiness of your status
hallucinations pointed out, aren't you?
... If it has wheels and an engine, it is a car ...

Not comparable. There are a whole lot of things with wheels and engines
which are, say, trucks -- members of other categories.

But "computer" is a top-level category, more like "vehicle". If it has
wheels (in the sense specifically of the kind used for travel, not including
all possible round spinny things, such as the rollers used to advance paper
in a large printing press) and an engine, it's a motor vehicle.

Someone who insists that something is only a "vehicle" if it has a steering
wheel on the left-hand side and is intended for use by commuters is wrong,
and someone who insists that something is only a "computer" if it is intended
for individual desktop use in conjunction with a keyboard and monitor is
wrong too.

-s
 
K

Keith Thompson

Nick Keighley said:
you could use a macro and diffuse all these arguments

#define TRUE -1

I quite like the grammer driven approach as an idea.
[...]

I think you mean

#define TRUE (-1)

And if I saw that, I'd still wonder why the author used -1 rather
than 1.

My own favorite way to define a Boolean type in C (if <stdbool.h>
isn't available) is

typedef enum { false=0, true=1 } bool;

where the "=0" and "=1" are superfluous, but nice to have for
emphasis.

But as long as you maintain the habit of *never* comparing for
equality to true or false, you can probably use any non-zero value you
like for true.
 
S

Seebs

But as long as you maintain the habit of *never* comparing for
equality to true or false, you can probably use any non-zero value you
like for true.

Long ago, I worked at a place that had some C++/Fortran interactions.

And the following macro:

#define IS_TRUE(x) ((x & 0x100) != 0)

Interestingly, after a compiler upgrade, that stopped working. Apparently
the Fortran compiler's value for .TRUE. had changed in some way that resulted
in that particular bit not being set. I was never able to get anyone to
explain what they thought this macro was good for, since .FALSE. was always
0.

-s
 
K

Kenny McCormack

Seebs said:
Someone who insists that something is only a "vehicle" if it has a steering
....

I don't exactly see a lot of argumentation or proof in your posts
either, dear boy...
 
F

Flash Gordon

bartc said:
Richard Heathfield said:
spinoza1111 wrote:

Grow up. Most platforms are Microsoft.

Absolute rubbish. [...] MS is a tiny drop in a rather large puddle.

I keep hearing all this. But since the 80's, most of the computers
I've been able to buy have come with a MS operating system. Most of
the rest have been Macs.

How many mainframe systems have you bought, personally, in the last
twenty years? How many minicomputer systems? And of course most of
the computers that you /have/ bought in the last twenty years aren't
MS platforms.

They don't seem to stock mainframes at PC World or Dixons.

So? That isn't where most computers (even most desktops and laptops, I
would guess), are bought.

Oh, and since you've said, since the 80s, there are the HP systems which
were in common use in some industries for which you had a choice of (to
my knowledge) three OSs NONE of which were by MS. These were computers
about the same size as an IBM PC, they had a keyboard, they had a
monitor, and where shipped with at least one programming language (I
used Pascal and BASIC) for software development *on* the machines.
It's fairly obvious when something is a computer, ie. a desktop or
laptop PC.

So servers are not computers? That will be interesting to my customer
who buy servers from computer manufacturers, and to the computer
manufacturers themselves who think they are building computers when they
build servers.
Everything else is more specialised.

Hmm. A computer running simultaneously three versions of Windows (all
server versions, so MS think servers are computers) and I think about 5
versions of Linux as well as the native OS is more specialised than a
computer only running one OS and far fewer applications?

Oh, and it's not long ago we had a customer asking us to port one of our
applications to AIX (a Unix version).
There might be some
consumer gadgets that are getting close though.

You mean like the netbook PCs running Linux? Or the PDAs on which you
can run word processors, spreadsheets, terminal emulators, games and
loads more are not computers?
 
B

bartc

Flash Gordon said:
bartc said:
Richard Heathfield said:
spinoza1111 wrote:

Grow up. Most platforms are Microsoft.

Absolute rubbish. [...] MS is a tiny drop in a rather large puddle.

I keep hearing all this. But since the 80's, most of the computers
I've been able to buy have come with a MS operating system. Most of
the rest have been Macs.

How many mainframe systems have you bought, personally, in the last
twenty years? How many minicomputer systems? And of course most of
the computers that you /have/ bought in the last twenty years aren't
MS platforms.

They don't seem to stock mainframes at PC World or Dixons.

So? That isn't where most computers (even most desktops and laptops, I
would guess), are bought.

My point-of-view is that of a hobbyist programmer. But even when I worked
for a (very small) company we were buying PCs with DOS or Windows, since
that was most of our clients had or could easily buy. I can't remember where
they were from, they just appeared.

(This has come up before and I understand some hobbyists do have esoteric
systems of various kinds.)
So servers are not computers? That will be interesting to my customer who
buy servers from computer manufacturers, and to the computer manufacturers
themselves who think they are building computers when they build servers.

Actually I've little idea what a server is. I'd imagine it's some machine
accessed across a network. I would call it specialised, although the way the
internet works is blurring some of the distinctions.

(I started in computing using timesharing terminals connected to a single
large computer. A few years later with no job I drifted into hardware and
started using simple microprocessor computers that were 100% personal and
hands-on.

Great! Finally we could get away from monster computers, operating systems,
logins, passwords, quotas, booking of terminals... but 25 years on and we're
drifting back in that same direction, and in spades...)
Hmm. A computer running simultaneously three versions of Windows (all
server versions, so MS think servers are computers) and I think about 5
versions of Linux as well as the native OS is more specialised than a
computer only running one OS and far fewer applications?

3 versions of Windows and 5 of Linux, and you think it's not specialised?..
You mean like the netbook PCs running Linux? Or the PDAs on which you can
run word processors, spreadsheets, terminal emulators, games and loads
more are not computers?

All I'm saying is that my world is dominated by computers running MS
products and I don't think that's an uncommon situation. (Not all of us are
lucky to have been given cool jobs developing for all these other systems
that are always mentioned.)

If I had to write a utility, let's say in C, to be sent to half a dozen
people I know, then if I compile it for x86-32 under Windows, I know they
will be able to run it. Compiled for anything else, they won't.
 
S

Seebs

If I had to write a utility, let's say in C, to be sent to half a dozen
people I know, then if I compile it for x86-32 under Windows, I know they
will be able to run it. Compiled for anything else, they won't.

Among people I know, my best bet would probably be OS X or x86 Linux.
Many of my friends don't have any access at all to Windows.

It varies some. :)

-s
 
S

spinoza1111

Among people I know, my best bet would probably be OS X or x86 Linux.
Many of my friends don't have any access at all to Windows.

It varies some.  :)

-s

What ev er. Any way, here is the next version of the parser under
discussion, with input from you and Bacarisse. Try to make
constructive comments only. Thanks.



// ***************************************************************
// * *
// * infix2PolishC Infix to Polish notation using a grammar *
// * *
// * *
// * This application converts infix to Polish notation using a *
// * simple grammar and two different implementations. It also *
// * contains testing and timing facilities. For more *
// * information, see the readme.TXT file in this project. *
// * *
// * *
// * C H A N G E R E C O R D --------------------------------- *
// * DATE PROGRAMMER DESCRIPTION OF CHANGE *
// * -------- --------- --------------------------------- *
// * 11 01 09 Nilges Version 1 *
// * *
// * 11 03 09 Nilges Version 2 *
// * ANON 1. Commenting added DONE *
// * 2. Routine index added with *
// * forward definitions DONE *
// * 3. Expected/actual cleanup DONE *
// * 4. Bug? Seems to convert Polish *
// * expression to value of first *
// * token without complaint *
// * FIXED *
// * 5. Minor bug: extra spaces in *
// * polish expression FIXED *
// * 6. Bugs as found by anon *
// * 8.1 1) FIXED *
// * 8.2 (((1)))) FIXED *
// * 7. Predetermine malloc using *
// * number of symbols other than *
// * parentheses and white space *
// * *
// * 11 04 09 Nilges Version 3 *
// * 1. Predetermine malloc using *
// * infix length times two *
// * 2. Detab code for posting *
// * 3. Free polish expression after *
// * displaying it in testcase() *
// * as noticed by Seebs and *
// * recommended by Schildt *
// * 4. Display purpose of code on *
// * entry *
// * 5. Option to specify malloc on *
// * command line for Polish *
// * expression (primarily to test *
// * storage usage) *
// * *
// * I S S U E S ----------------------------------------------- *
// * DATE POSTER DESCRIPTION AND RESOLUTION *
// * -------- --------- --------------------------------- *
// * 11 03 09 Nilges Version 4 plan *
// * 1. Random expressions *
// * 2. Integrate in GUI with C sharp,*
// * versions from Gene, Seebach *
// * & anon *
// * 3. Post versions from Gene and *
// * Anon and Seebach version *
// * *
// ***************************************************************

#include <stdio.H>
#include <stdlib.H>

// ***** Constants ***********************************************
#define ABOUT_INFO \
"This application converts infix to Polish notation using a simple
grammar-based approach."

// ***** Macros **************************************************

// --- Pass over white space
#define SKIP_WHITE_SPACE(s, i, e) \
{ for(; (i) <= (e) && (s)[(i)] == ' '; (i)++ ); }

// --- Return maximum value
#define MAX(x, y) ((x) > (y) ? (x) : (y))

// ***** Function index ******************************************
#define ADDFACTOR \
int addFactor(char *strInfix, \
char *strPolish, \
int *intPtrIndex, \
int intEnd, \
int intMaxPolishLength)
ADDFACTOR;
#define ERRORHANDLER \
int errorHandler(char *strMessage)
ERRORHANDLER;
#define ERRORHANDLERSYNTAX \
int errorHandlerSyntax(int intIndex, \
char *strMessage, \
char *strInfix)
ERRORHANDLERSYNTAX;
#define EXPRESSION \
int expression(char *strInfix, \
char *strPolish, \
int *intPtrIndex, \
int intEnd, \
int intMaxPolishLength)
EXPRESSION;
#define FINDCHARS \
int findChars(char *strInstring, \
char *strFind, \
int intStartIndex)
FINDCHARS;
#define INFIX2POLISH \
int infix2Polish(char *strInfix, \
char *strPolish, \
int intMaxPolishLength)
INFIX2POLISH;
#define MAIN \
int main(int intArgCount, \
char *strArgs[])
MAIN;
#define MULFACTOR \
int mulFactor(char *strInfix, \
char *strPolish, \
int *intPtrIndex, \
int intEnd, \
int intMaxPolishLength)
MULFACTOR;
#define STRING2UNSIGNEDINT \
int string2UnsignedInt(char *strInstring)
STRING2UNSIGNEDINT;
#define STRINGAPPENDCHAR \
int stringAppendChar(char *strString, \
char chrNew, \
int intMaxLength, \
int intSpaceBefore)
STRINGAPPENDCHAR;
#define STRINGLENGTH \
int stringLength(char *strInstring)
STRINGLENGTH;
#define TESTCASE \
void testCase(char *strInfix, \
char *strExpected, \
int intMalloc)
TESTCASE;
#define TESTER \
void tester(int intMalloc)
TESTER;

// ***** Functions ***********************************************

// ---------------------------------------------------------------
// Command line handler
//
// int main(int intArgCount, char **strArgs)
//
MAIN
{
int intMalloc = -1;
printf("%s\n\n", ABOUT_INFO);
if (intArgCount > 1)
if ((intMalloc = string2UnsignedInt(strArgs[1])) < 0)
{
printf("%sInvalid malloc request %s\n", intMalloc);
return;
}
tester(intMalloc);
printf("\n\nTesting complete: check output for correctness");
return;
}

// ---------------------------------------------------------------
// Parse add factor
//
// int addFactor(char *strInfix,
// char *strPolish,
// int *intPtrIndex,
// int intEnd,
// int intMaxPolishLength)
//
// addFactor = mulFactor [ *|/ mulFactor ]
//
ADDFACTOR
{
char chrMulOp = ' ';
int intStartIndex = 0;
if (!mulFactor(strInfix,
strPolish,
intPtrIndex,
intEnd,
intMaxPolishLength))
{
errorHandlerSyntax(*intPtrIndex,
"mulFactor not found",
strInfix);
return 0;
}
if (*intPtrIndex > intEnd) return -1;
intStartIndex = *intPtrIndex;
while (1)
{
SKIP_WHITE_SPACE(strInfix, (*intPtrIndex), intEnd)
if (*intPtrIndex > intEnd) break;
if ((chrMulOp = strInfix[*intPtrIndex]) != '*'
&&
chrMulOp != '/')
return -1;
(*intPtrIndex)++;
if (*intPtrIndex > intEnd
||
!mulFactor(strInfix,
strPolish,
intPtrIndex,
intEnd,
intMaxPolishLength))
return errorHandlerSyntax
(*intPtrIndex,
"Mul/div op not followed by mulFactor",
strInfix);
if (!stringAppendChar(strPolish,
chrMulOp,
intMaxPolishLength,
1)) return 0;
}
return -1;
}

// ---------------------------------------------------------------
// Error handler
//
// int errorHandler(char *strMessage)
//
ERRORHANDLER
{
printf("\n%s\n", strMessage); return 0;
}

// ---------------------------------------------------------------
// Syntax error handler
//
// int errorHandlerSyntax(int intIndex,
// char *strMessage,
// char *strInfix)
//
ERRORHANDLERSYNTAX
{
int intIndex1 = 0;
printf("\nError at character %d: %s\n",
intIndex,
strMessage);
printf("%s\n", strInfix);
for (intIndex1 = 0; intIndex1 < intIndex; intIndex1++)
printf(" ");
printf("$");
return 0;
}

// ---------------------------------------------------------------
// Parse expression
//
// int expression(char *strInfix,
// char *strPolish,
// int *intPtrIndex,
// int intEnd,
// int intMaxPolishLength)
//
EXPRESSION
{ /* expression = addFactor [ +|- addFactor ] */
char chrAddOp = ' ';
int intStartIndex = 0;
if (!addFactor(strInfix,
strPolish,
intPtrIndex,
intEnd,
intMaxPolishLength))
{
errorHandlerSyntax(*intPtrIndex,
"addFactor not found",
strInfix);
return 0;
}
intStartIndex = *intPtrIndex;
while (1)
{
SKIP_WHITE_SPACE(strInfix, (*intPtrIndex), intEnd)
if (*intPtrIndex > intEnd) break;
if ((chrAddOp = strInfix[*intPtrIndex]) != '+'
&&
chrAddOp != '-')
return
errorHandlerSyntax
(*intPtrIndex,
"Unrecognizable char found instead of add op",
strInfix);
(*intPtrIndex)++;
if (*intPtrIndex > intEnd
||
!addFactor(strInfix,
strPolish,
intPtrIndex,
intEnd,
intMaxPolishLength))
return errorHandlerSyntax
(*intPtrIndex,
"Add/sub op not followed by addFactor",
strInfix);
stringAppendChar(strPolish,
chrAddOp,
intMaxPolishLength,
1);
}
return -1;
}

// ---------------------------------------------------------------
// Find one of a set of alternative characters
//
// int findChars(char *strInstring,
// char *strFind,
// int intStartIndex)
//
FINDCHARS
{
int intIndex1 = intStartIndex;
int intIndex2 = 0;
for (; strInstring[intIndex1] != '\0'; intIndex1++)
for (intIndex2 = 0;
strFind[intIndex2] != '\0';
intIndex2++)
if (strInstring[intIndex1] == strFind[intIndex2])
return intIndex1;
return intIndex1;
}

// ---------------------------------------------------------------
// Convert infix to Polish
//
// int infix2Polish(char *strInfix, int intMalloc)
//
INFIX2POLISH
{
int intIndex = 0;
int intLength = stringLength(strInfix);
strPolish[0] = '\0';
if (!expression(strInfix,
strPolish,
&intIndex,
intLength - 1,
intMaxPolishLength))
{
errorHandler("Error");
return 0;
}
return -1;
}

// ---------------------------------------------------------------
// Parse multiplication factor
//
// int mulFactor(char *strInfix,
// char *strPolish,
// int *intPtrIndex,
// int intEnd,
// int intMaxPolishLength)
//
// mulFactor = LETTER | NUMBER | '(' expression ')'
//
MULFACTOR
{
int intIndexStart = 0;
int intLevel = 0;
char chrNext = ' ';
int intInner = 0;
int intSpaceBefore = 0;
SKIP_WHITE_SPACE(strInfix, (*intPtrIndex), intEnd)
if (*intPtrIndex > intEnd)
return errorHandlerSyntax(*intPtrIndex,
"mulFactor unavailable",
strInfix);
chrNext = strInfix[*intPtrIndex];
if (chrNext >= 'a' && chrNext <= 'z')
{
(*intPtrIndex)++;
return stringAppendChar(strPolish,
chrNext,
intMaxPolishLength,
1);
}
intIndexStart = *intPtrIndex;
intSpaceBefore = -1;
while(*intPtrIndex <= intEnd
&&
(chrNext = strInfix[*intPtrIndex]) >= '0'
&&
chrNext <= '9')
{
if (!stringAppendChar(strPolish,
chrNext,
intMaxPolishLength,
intSpaceBefore))
return 0;
intSpaceBefore = 0;
(*intPtrIndex)++;
}
if (*intPtrIndex > intIndexStart)
return -1;
if (chrNext == '(')
{
intLevel = 1;
(*intPtrIndex)++;
intInner = *intPtrIndex;
while (intLevel > 0 && *intPtrIndex <= intEnd)
{
if ((chrNext = strInfix[(*intPtrIndex)++]) == '(')
{
intLevel++;
}
else
{
if (chrNext == ')')
{
intLevel--;
}
}
}
if (intLevel != 0)
return errorHandlerSyntax
(*intPtrIndex,
"Unbalanced left parenthesis",
strInfix);
if (!expression(strInfix,
strPolish,
&intInner,
*intPtrIndex - 2,
intMaxPolishLength))
return errorHandlerSyntax
(intInner,
"Expression doesn't appear in parentheses",
strInfix);
return -1;
}
return 0;
}

// ---------------------------------------------------------------
// Convert string to an unsigned integer
//
// int string2UnsignedInt(char *strInstring)
//
//
STRING2UNSIGNEDINT
{
int intIndex1 = 0;
int intValue = 0;
for (; strInstring[intIndex1] != '\0'; intIndex1++)
{
if (strInstring[intIndex1] < '0'
||
strInstring[intIndex1] > '9') break;
intValue = intValue * 10
+
strInstring[intIndex1] - (int)'0';
}
return intValue;
}

// ---------------------------------------------------------------
// Append character to string
//
// int stringAppendChar(char *strInstring,
// char chrNew,
// int intMaxLength,
// int intSpaceBefore)
//
STRINGAPPENDCHAR
{
int intLength = stringLength(strString);
int intSpaceBeforeInEffect =
intSpaceBefore
&&
intLength > 0
&&
strString[intLength - 1] != ' ';
if (intLength
intMaxLength - (intSpaceBeforeInEffect ? 2 : 1))
{
errorHandler
("Cannot append character(s): insufficient storage");
return 0;
}
if (intSpaceBeforeInEffect)
{
strString[intLength++] = ' ';
}
strString[intLength] = chrNew;
strString[intLength + 1] = '\0';
return -1;
}

// ---------------------------------------------------------------
// Return string length
//
// int stringLength(char *strInstring)
//
STRINGLENGTH
{
int intIndex1;
for (intIndex1 = 0;
strInstring[intIndex1] != '\0';
intIndex1++) { }
return intIndex1;
}

// ---------------------------------------------------------------
// Test case
//
// void testCase(char *strInfix, char *strExpected, int intMalloc)
//
TESTCASE
{
char *strPolish;
int intMaxPolishLength = 0;
int intReq = intMalloc > 0
?
intMalloc
:
MAX((intMaxPolishLength
=
stringLength(strInfix) << 1)
+
1,
10);
printf("\n\nConverting \"%s\": expect \"%s\"",
strInfix,
strExpected);
strPolish = (char *)malloc(intReq);
if (strPolish == 0)
errorHandler("Can't get storage");
printf("\n\"%s\"\n",
(infix2Polish(strInfix,
strPolish,
intMaxPolishLength)
?
strPolish
:
"Conversion failed"));
free(strPolish); // cf. Schildt, C: the Complete Reference
}

// ---------------------------------------------------------------
// Tester
//
// void tester()
//
TESTER
{
testCase("1", "1", intMalloc);
testCase("1+1", "1 1 +", intMalloc);
testCase("(10+613)*a", "10 613 + a *", intMalloc);
testCase(")", "Error", intMalloc);
testCase("1)", "Error", intMalloc);
testCase("(((1))))", "Error", intMalloc);
testCase("10 113 + a *", "Error", intMalloc);
testCase("(10 + 113) * a", "10 113 + a *", intMalloc);
testCase(" ( 10 + 113 ) * a ", "10 113 + a *", intMalloc);
testCase("(", "Error", intMalloc);
testCase("((((2", "Error", intMalloc);
testCase("////2", "Error", intMalloc);
testCase("", "Error", intMalloc);
testCase("()", "Error", intMalloc);
testCase("(((5))", "Error", intMalloc);
testCase("(((5)))", "5", intMalloc);
testCase("((5))", "5", intMalloc);
testCase("5", "5", intMalloc);
testCase("((10+(113-(2+((((((2/(4+3)))))))+2+2))))*a", "10 113 2 2
4 3 + / + 2 + 2 + - + a *", intMalloc);
testCase("a", "a", intMalloc);
testCase(" a + b ", "a b +", intMalloc);
testCase(" a + b ", "Malloc bound failure", 5);
}
 
B

Ben Pfaff

spinoza1111 said:
#define ADDFACTOR \
int addFactor(char *strInfix, \
char *strPolish, \
int *intPtrIndex, \
int intEnd, \
int intMaxPolishLength)
ADDFACTOR;

This is a very strange coding style.
 
S

spinoza1111

This is a very strange coding style.

That is an unconstructive comment. 99.999% of code (esp C) doesn't
work and sucks stylistically. he only decent code I ever saw besides
my own and a man who was bullied at Bell Northern Research was by John
Nash. Anyway, when in Rome, don't do as the Romans do, especially if
they are a pack of bloody fools as is on display in this ng.
 
S

spinoza1111

[...]> you could use a macro and diffuse all these arguments
#define TRUE -1
I quite like the grammer driven approach as an idea.

[...]

I think you mean

#define TRUE (-1)

And if I saw that, I'd still wonder why the author used -1 rather
than 1.

My own favorite way to define a Boolean type in C (if <stdbool.h>
isn't available) is

    typedef enum { false=0, true=1 } bool;

where the "=0" and "=1" are superfluous, but nice to have for
emphasis.

But as long as you maintain the habit of *never* comparing for
equality to true or false, you can probably use any non-zero value you
like for true.

That is correct. And what's the best? The one you can see on blue
screen of death style dumps? When twos complement is in use?

My stars it is -1.

Case closed.

Course I never get blue screen of death but you should use it in the
event you do.
 
S

Seebs

This is a very strange coding style.

I hypothesize that the intent is to allow both a declaration and a
definition to use the same code.

I agree that it's pretty odd, though.

-s
 
S

Seebs

That is correct.

It is.
And what's the best? The one you can see on blue
screen of death style dumps?

No.

The best is the one that other people will recognize when they read your
code, and which is the value yielded by the boolean operators.
Case closed.

Wrong.

Imagine, for the sake of argument, that you do this.

And then you see a dump which includes the results of boolean operators.

If you think "00000001" is hard to see in a field of "00000000", that's
nothing; what's hard is to see it when you've mistrained yourself to think
of only "11111111" as a "true" value.

Meanwhile, when using any code written by other people, you'll constantly
be seeing -1 values which you misinterpret as "true" when they were error
indicators.

Nope. It's a side-of-the-road issue; your argument about why it should be
otherwise is not strong enough to justify driving on the wrong side of
the road.
Course I never get blue screen of death but you should use it in the
event you do.

Of course. Interesting how it wasn't until I made a comment about the
reliability of MS systems that you suddenly switched from the BSoD being
a major consideration to it never happening.

-s
 
S

spinoza1111

Because my opinions are frequently right.

Look at it this way:  Who is better at mathematics, someone who knows all the
standard trigonometry relationships, or someone who can't remember them but
can rederive them on the fly any time they come up?

Don't break your arm patting yourself on the back, Einstein. You
confuse knowledge and bias resulting from overspecialisation with
scientific knowledge.
That's a "complaint".  (It's also patently false, as at least some people
appear to accept it.)


Being a cautious sort, I did consider this as a possibility, briefly.  I have
shown your arguments to a broad selection of people with either different
learning disorders or none that we know of.  The responses are essentially
consistent; everyone thinks you're a nutter.  This would be because you don't

So you show them around to the guys at the office and these dweebs in
some corporation think I'm a nutter. Hey, two can play that game: the
tech reviewers at McGraw Hill probably think you are.
HAVE any reasoning, just various assertions offered as a sort of miasma
of impotent rage against C.


Did.

Know, I don't think you have. Calling people "nutters" is 14 year old
argumentation.
Not really.  Most desktop computers are Microsoft -- but much of what
Schildt wrote is no longer true of them.  The vast majority of CPUs running
C code, though, are not running MS operating systems, and many of the ones
which are are cell phones or other devices which, again, don't conform to
the rules Schildt discussed.

This is bullshit. As I have said, he was using a model to illustrate
how things work for normal people as opposed to autistic twerps, and
expected them properly to see the essentials, just as I used Sherman's
7094 based book in 1970 although the labs were on the 1401.
But even if it were true, the best case is that we reduce the set of errors
to about two thirds of its current size, and observe that the other third
of the "errors" were in fact a single error, the claim that the book covered
all systems and portable code.  That would get us from incompetence about C
to mere fraud, doubtless an improvement.  :)

You're lying and I think you're going to end up in a court of law,
since your document said that the 20 errors you listed, most of which
were bullshit (and all of which were rejected by technical people at
McGraw Hill) were the known errors, and you have never shown us the
"hundreds" of other errors that you claimed, in a self-contradictory
way, were "also" in the book.

Even if you were right, you'd still be wrong.

The job of a technical writer is to describe what is, not just what
should have been.

I'd hate to see you dealing with history books.  "Schildt's claim that
the Japanese never attacked Pearl Harbor is ridiculous."  "But that would
have been a horrible mistake; they'd have gotten America into WWII and
probably subsequently lost the war.  Clearly, it was the Japanese that
made the mistake, Schildt is correct."


Doesn't matter.  It's what is.  It is an error for the book to describe
things incorrectly, *even if you don't like the way they are*.

Again, you documented only 20 errors and have never, to my knowledge,
provided a longer list. Of the errors you documented, some were
matters of opinion and interpretation, and others were trivia.

Hard working, professional and collegial programmers, in a multivendor
environment such as the environment I worked at Bell-Northern
Research, when given code let us say that #includes file names in
upper case, that was developed on IBM or Microsoft platforms, simply
correct the code for case sensitivity.

It's called doing your job, asshole.

But autistic twerps and bullies instead sit on the code and when asked
where it is, say "oh, it's got hundreds of errors and I cannot work
with it boo hoo Mommy".

I think you subconsciously replicate your on the job behavior patterns
here. I would not hire you nor would I recommend you for a programming
job.

Untrue.  We've pointed you at several instances.

Who's "we?" A vanishingly small set of twerps, one of whom is probably
being paid to harass people and sow dissension by SAMS publishing (a
known unethical publisher), sitting behind computer screens jerking
off.
Untrue.  No one has been identified as having said this.  Seriously, find
an example.


No, you haven't.  You've claimed that you have, but normally you just post
non-sequiturs, occasionally you post untrue things.


I never knew that junior high school students were the epitome of
"corporate-speak".

Actually, the corporation preserves high school relationships in order
to disempower people.
Only it isn't.  It isn't what I've done with Schildt, either.

I've passed on verified factual claims with substantiation and support.

You're lying. Again, "C: The Complete Nonsense" only lists as
confirmed 20 errors while making reference to "hundreds" in a self-
contradictory fashion, and it is the source, as far asI have
determined, for all the claims about C: The Complete Reference.
The support's strong enough that you're now reduced to claiming that
the real world should have been different so that the book wouldn't be
wrong.  That's... Well, it's funny, and it's why I see no evidence
that *anyone* is taking you seriously anymore.


Again, "yes it is".  Go look at the Google Groups archives from back when
his books were popular.


Not demonstrably.


I understand those fine.  However, that doesn't make the book correct; that
makes the book incorrect in a way that many users recover from.

Here's the great part.

Critical thinking is what happens when people realize that a source is
unreliable.  One of the ways this can be streamlined is to tell them about it
up front.  Then, they critically think about the value of the book, toss
it in the trash, and get one that doesn't suck.

This would be "Schildt is better for Microsoft platforms". Note that
you could have expressed it this way, but instead you preferred to air
your ignorance about Microsoft platforms. For example, you seem
unaware that at the time, file identifiers were case insensitive.
You're paying the price of being treated in the same way you treated
Schildt.
Fascinating assertion.  Not particularly supported, but fascinating.


You continue to hammer home the fact that you have no clue what you're
talking about.  The "data types" you need to know are at the level
of "structure" or "integer"; if you think you need to know whether something
is an int or a long during the design phase, your design is flawed.

This is just wrong. In fact, you need to know ranges of data in the
design phase. Failure to do so causes common bugs.
This makes no sense.  Why should the categories be mutually exclusive?
If they are mutually exclusive, which are you?

Neither, thank God, since after 1980, a new generation of self-serving
twerps entered programming.

What is YOUR job title and company, please?
 
S

spinoza1111

I hypothesize that the intent is to allow both a declaration and a
definition to use the same code.

I agree that it's pretty odd, though.

It is meant to fix a bug in basic C that may have other fixes. This is
of course that

(1) Functions must be defined before use (an idiot language feature
since it is an artifact of the thrilling days of yesteryear when
storage was limited, and programs were on paper tape and could not,
conveniently, be read more than once)

(2) Fixing this problem (which is an iinsult to the intelligence) in
the ordinary way means coding the declaration twice.

If you know a better way to fix the problem, what is it?

My way gives a nice little overview and is reasonably easy to
maintain.
 
S

spinoza1111

It is.


No.

The best is the one that other people will recognize when they read your
code, and which is the value yielded by the boolean operators.


Wrong.

Imagine, for the sake of argument, that you do this.

And then you see a dump which includes the results of boolean operators.

If you think "00000001" is hard to see in a field of "00000000", that's
nothing; what's hard is to see it when you've mistrained yourself to think
of only "11111111" as a "true" value.

Any form of narrow specialization, I agree, can stunt the mind which
is why the category of "expert in a programming language" is an
immoral category UNLESS it means some little clerk we can summon to
check our code and then dismiss without having to listen to his
opinions. Rest assured that my code doesn't cause blue screen of
death. The last time I had to deal with what used to be called "core
dumps" as at Princeton using IBM mainframe assembler.

Kiki: if it's zero in C it is false (which renders arguments to the
effect that zero indicates "okay" elsewhere moot). Anything else is
true.

Nilges: ok, then, truthiness should be as unlike falsiness as
possible. Therefore -1.

No, C does NOT have Booleans, since safe C means using as little crap
as possible and I don't get Booleans when I do so.
Meanwhile, when using any code written by other people, you'll constantly
be seeing -1 values which you misinterpret as "true" when they were error
indicators.

No, I won't. Autistics need Mommy to make things all neat. Men don't.
Nope.  It's a side-of-the-road issue; your argument about why it should be
otherwise is not strong enough to justify driving on the wrong side of
the road.

I would never drive on a road designed by you, so the point is moot.
 
S

spinoza1111

What ev er. Any way, here is the next version of the parser under
discussion, with input from you and Bacarisse. Try to make
constructive comments only. Thanks.

// ***************************************************************
// *                                                             *
// * infix2PolishC   Infix to Polish notation using a grammar    *
// *                                                             *
// *                                                             *
// * This application converts infix to Polish notation using a  *
// * simple grammar and two different implementations. It also   *

Correction: "two different implementations" is incorrect. At this time
there is only one implementation.
 
S

spinoza1111

What ev er. Any way, here is the next version of the parser under
discussion, with input from you and Bacarisse. Try to make
constructive comments only. Thanks.

// ***************************************************************
// *                                                             *
// * infix2PolishC   Infix to Polish notation using a grammar    *
// *                                                             *

// *                                                             *
// ***************************************************************

#include <stdio.H>
#include <stdlib.H>

The use of an upper case H should also have been corrected per a
comment by Seebach.
 

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
474,079
Messages
2,570,573
Members
47,205
Latest member
ElwoodDurh

Latest Threads

Top