usage of size_t

S

spinoza1111

spinoza1111wrote:


You appear to misunderstand (but see below) the nature of idioms. By the
time they are sufficiently popular to have /become/ idioms, their origin
is almost certainly lost in the mists of time. Not necessarily the case,
of course. I imagine that while(*s++=*t++); is probably straight out of
dmr's head. But even with that obvious example, I'm not sure.

But if you simply mean that you won't choose the same idioms that Seebs
chooses, that's plain dumb. It's like saying you'll refuse to take a bus
to work because there's a guy you don't trust, working for a completely
different company in a completely different country, who takes the bus
to work, so clearly it must be a bad choice. If that's your position,
it's idiotic.

No, it's because Seebs is not qualified, Analogy Monster. Why should I
adopt demotic speech when it fails to express what needs to be
expressed? That's Idiocracy.
 
S

spinoza1111

spinoza1111wrote:
But if you simply mean that you won't choose the same idioms that Seebs
chooses, that's plain dumb. [...]
No, it's because Seebs is not qualified,

You keep saying this, but I've seen his C and I've seen your C, and
yours is a lot worse than his.

Strange, because I've seen no Seebie C without bugs, whereas I've
converged in far more ambitious projects on bug free code. I promised
Mr. Dan Appleman that the 26000 line compiler in Build Your Own would
run all examples correctly, and using stress testing, I made it do so:
note that the NORMED situation in a corporation is literally that bugs
don't get fixed and the software is delivered anyway, with the thugs
in charge usually finding the least powerful to blame. The replace()
solution is now probably bug free after blm noticed that it failed to
handle a null master string.

Whereas Seebach REFUSES to fix his bugs. I've never see him do so. Not
even for the one-line strlen, nor for the silly %s replacement.

Furthermore, his code is laid out sloppily with contempt of the
reader.

And neither of you are capable of writing literate code with
meaningful identifiers. Nor are you capable of writing other than
corporate English.

This is why you're inflamed with resentment. You're subhumans who have
been corrupted, and you rage against the light. So to put it in a
nutshell: to paraphrase what Gus Avrakatos said in Charley Wilson's
war, I just like from time to time to review the many ways in which
you and Seebach are douchebags.
 
S

spinoza1111

spinoza1111wrote:
spinoza1111wrote:
<snip>
But if you simply mean that you won't choose the same idioms that Seebs
chooses, that's plain dumb. [...]
No, it's because Seebs is not qualified,
You keep saying this, but I've seen his C and I've seen your C, and
yours is a lot worse than his.
Strange, because I've seen no Seebie C without bugs,

I understand that your experience of Seebs's code is limited. Mine, too,
  is limited, but less so. And I've seen a fair amount of your code over
the years. His is considerably less buggy.

That's simply untrue, based on his behavior over the past month. As
far as I can tell, he either posts code with bugs intentionally, or
unintentionally.

We all write bugs. It's a well-known fact about software writing. The
critical difference is what we do about them. Unlike most other
posters here, Seebach does not, as far as I can see, make any effort
to correct his bugs.

Instead, he dismisses the problem as trivial and not worthy of his
time and attention.

In the most absurd statement to date, he described replace() as "a
first year computer science problem" when he has NOT taken a single
computer science class, and would have no reason for knowing this!
Indeed, his statement was Fascistic: characteristic of Fascism is to
rely on universities for certification for technical and military
assignments, while dismissing all actual instances of university
personnel as ignorant examples of a fancied ideal. Thus Seebach, as a
Fascist, feels justified in absurdly appealing to university work as
certification without having accomplished that work.
 
N

Nick Keighley

My sirname begins with L. But you SHOULD know that from the email I sent
you.

As it happens, a debugger is PERFECT for seeing how it works. If you dont
realise this then you're a bigger idiot that you appear.

Run the debugger and step the loop keeping an eye on the locals. Set a
breakpoint maybe for the terminal conditions such as i==1 or 0 etc.

without reading a book it's not blindingly obvious i++ and ++i are
different.

If you do not see that as being useful for someone learning C then thank
god you're not in a position to teach anything.  While we all realise
you have a very high opinion of your self worth, please dont spread your
own ignorance of how to use such useful tools.


if some lurker is left wondering who is "right" be aware there is a
genuine disagreement here. Some people think the way to learn what a
construct is supposed to do is to read a good tutorial (such as K&R)
(and write lots of code!). And others who prefer to "see the code
execute". There are experienced programmers on both sides of this
fence.

And, yes, I have helped people learn C.
 
N

Nick Keighley

That's a good reason for dropping the special operators.
However count = count + 1 is a construct needed so frequently that it
helps to have a special syntax for it.
In my idiom x = x + 1 and x++ are not equivalent. x++ is increemnting,
x = x+1 is adding a constant which, coincidentally, is unity.
An example is scores for matches in association football. The old rule
was 2 points for a win, one for a draw, zero for a loss. Now the rule
is 3 points for a win, one for a draw, zero for a loss. However they
could easily decide that the win premium is too great and make it five
for a win, three for a draw. Using the ++ operator to increment the
total for a draw wuld be inappropriate.

but so would embedding "1" in the code
 
M

Malcolm McLean

In fact, I
*rarely* use a debugger, and pride doesn't enter into it.
I used to use debuggers extensively when I started writing in C. The
problem, I found, was that the debugger became a very intimate part of
the way I worked. When it was taken away, it was a bit like trying to
drive without an automatic clutch - it can be done, in fact lorry
drivers still double declutch - but it requires a different way of
thinking.
Since I have to program on platforms without debuggers as frequently
as on platforms with them, it was easier to do without. Also,
debuggers take some learning.
 
M

Michael Foukarakis

Michael Foukarakis wrote:

for(i = 0; i < N; i++) {
        foo(bar;
}

is a million (give or take) times clearer than your solution, is
probably what any C newbie has been taught first in the subject of
loops, and conveys exactly the intended behaviour.

Not if the intent is to count /down/ (which is in fact what we're
talking about here).


Ah well, then my post doesn't make sense. I assumed the intent was to
iterate over the contents of the array and direction was irrelevant.
 
S

spinoza1111

spinoza1111wrote:


I think that all people here are pretty qualified programmers...
including you

Well said. Richard is a creep, but I have said he knows more C than I.
In terms of what corporations say they need, that's all that seems to
be required these days. My conception of a "good programmer" is
someone so remote from corporate "needs" as to be a Platonic myth in
many ways. Basically, the elections of Reagan and Thatcher sent the
message: we don't want truly qualified people in such a lowly
position. We want yobs (who in the 1990s were working in the City of
London, dressed in finery, but who spent their holidays savagely
attacking Europeans).
 
S

spinoza1111

spinoza1111wrote:


You seem to be basing your judgement on a single careless Usenet
article. I am basing mine on a wider sample.

I would note in passing that the single bug you're talking about was
noticed almost immediately by quite a few people, and he acknowledged it
forthwith.

It wasn't noticed by him, nor was it noticed by Keith Thompson after
that stuffed shirt gravely examined the code.

Furthermore, Seebie has never fixed his %s bug.

Talk about quirks. If Seebie can use stylistic quirks, and you can use
failure to exclude a harmless malloc.h, to make absurd generalizations
about competence, I shall use hard, gnarly, stupid bugs as an
indication of a staggering incompetence, especially when the bebugger
has prepared the ground by scapegoating, bragging about his lack of
qualifications and in general being a flaming asshole.

Even you haven't posted in my experience a strlen that was off by one.
All you did was make an unpredictably-behaving mess out of a simple
problem.
 
S

spinoza1111

spinoza1111wrote:


The bug was reported very quickly, so neither of them /needed/ to notice
it themselves.


I'll leave that to Seebs to answer.


If it adds no benefit (which it didn't), and causes compilation failure
(which, on some systems, it did), it can hardly be caused harmless.

That's absurd. Look, buddy, your ridiculous linked list can
unpredictably bring systems down if it is passed large objects. By the
reasoning you use above, your code is buggy because it *can* fail. Why
do you persist in subjecting your own pet projects to a radically
different standard than you use for people you resent?
 
A

Andrew Poelstra

And why is the square root of -1 used as a subscript all the time?
That's seriously weird.

Well, if you accept that i is the multiplicadditive identity,
it feels a little less funny to denote it as "imaginary" and
a lot more natural for it to equal one less than itself.

;)


Andrew
 
S

Seebs

I'll leave that to Seebs to answer.

I have no clue what he's talking about.

If that's the "bug" that the first replacement code I posted checked for %
and assumed it meant %s, that wasn't a bug, that was a carefully chosen
assumption in a context where I controlled the inputs. Anyway, the second
version I posted clearly fixed that, and had only one remaining bug that I
know of -- it would hang if you gave it an empty needle. I posted a fix
for that.

So my string replace program, written in ten minutes before breakfast, appears
to have had a single bug, which took about two minutes to fix.
spinoza1111's, written over the course of a couple of hours, appears to have
had at least five which took him another four or five hours to fix (total,
not each).

Clearly, this somehow makes my code buggier. I'd think maybe he meant that I
had more bugs per line of code in mine, but I think it was long enough that I
didn't.

-s
 
S

spinoza1111

spinoza1111wrote:


What benefit does it add that justifies the risk of compilation failure?

And what planet are you from? And from what comic books did you learn
your trade?

Alice: Doctor Nilges, you fool! A compilation error will occur! Have
you gone mad?
Nilges: Shut up, woman! I know what I am doing! Zey laughed at me at
Princeton but I VILL #include malloc.h in zis code! It verks on
Microsoft Vindows, vy not here!
Skippy: Mommy, mommy I'm scared!
Ruff: Woof! Woof!
Computer: COMPILATION ERROR. LIFE SUPPORT SYSTEMS SHUTTING DOWN.

(Screams)

You get JOBS because code is PORTED. If malloc.h is NOT included it
will fail on some C compilers. In fact, if you knew as much of the C
"big picture" as you know of its details, you'd know that the only way
to write portable code for all platforms is to use the preprocessor,
and you'd know that in C sharp and Java this is not necessary.
Feel free to demonstrate how. I'm reasonably sure that I've catered for
that possibility using failure codes to indicate where memory is not
available to store an object, but do you have a counter-example?

I saw no try catch in your code. However, it does check the return
from malloc: good job, Skippy.

But that wasn't the problem I was thinking of. I was thinking of a
type of problem which "consultants" characteristically ignore, because
too many "consultants" (a glorified word for temp without tits) engage
in hit and run, producing code not guaranteed to work once they've
absconded with the swag.

In cases where there's (just) enough memory, the code will not
fail...just run like a pig.

The default solution, which it does not appear you've learned, avoids
this.
I disagree that my reasoning leads to such a conclusion.

Code that runs too slowly to do its job is a failure, Skippy.
 
S

spinoza1111

I have no clue what he's talking about.

If that's the "bug" that the first replacement code I posted checked for %
and assumed it meant %s, that wasn't a bug, that was a carefully chosen
assumption in a context where I controlled the inputs.  Anyway, the second
version I posted clearly fixed that, and had only one remaining bug that I
know of -- it would hang if you gave it an empty needle.  I posted a fix
for that.

OK, very good, if what you say is true. But in my recollection you
fixed it only after I pointed out your lack of professionalism. You
then followed up with a magnificent example of incompetence, because
nobody in his right mind here, with so many people here ready to kick
your butt, would have NOT proofread or tested your idiotic
stringlength.

I should have a look at your fix. My guess is it introduces a further
bug, since your whole approach was wrong.
So my string replace program, written in ten minutes before breakfast, appears
to have had a single bug, which took about two minutes to fix.spinoza1111's, written over the course of a couple of hours, appears to have
had at least five which took him another four or five hours to fix (total,
not each).

Apples and oranges. You wrote unformatted and ugly slop. Anybody can
do that "before breakfast". I discarded string.h, which was my problem
statement, I did far more, and far more neatly formatted documentation
than is found in your crap. I researched Boyer Moore and KMP, and
developed a new approach for handling partial matches. I described
each bug in the place where that description can be found, and
credited contributors.

And I've said it before. Little corporate slaveys, as Marcuse's one
dimensional man, rate themselves by a one dimensional scale: time to
some crap "working". They then insult anyone who questions their lack
of diligence, or that sort of passion for programming and curiosity
which prefers to have a decent amount of time in which to do a proper
job.
Clearly, this somehow makes my code buggier.  I'd think maybe he meant that I
had more bugs per line of code in mine, but I think it was long enough that I
didn't.

Hey asshole: try addressing the person you're insulting by name and
using the second person.
 
S

Seebs

Make-work, you mean? Not interested, thanks.

You can't possibly be surprised by this. Consider his assertion that if
it was hard to write, it should be hard to read. Clearly, this is a man
devoted to trying to create job security by every possible tactic other
than actually being good at his job.
Wrong. Any conforming implementation *must* provide malloc's and free's
declarations in <stdlib.h>

More importantly: Let's say that we take him to mean "some compilers for
variants of C, which are not actually conforming".

Okay. Name one. Here's a test program:

#include <stdlib.h>
/* #include <malloc.h> */
int main(void) {
void *p = malloc(1);
free(p);
return 0;
}

Name a compiler on which this fails, but where if you uncommented the
second line, it would work. The compiler must have shipped some time
after 1992 -- it can't be old enough to vote.

-s
 
J

Julienne Walker

I saw no try catch in your code.

Probably because there's no such construct in portable C. You can
simulate exceptions using standard C, but it gets ugly very quickly.
In cases where there's (just) enough memory, the code will not
fail...just run like a pig.

I don't see how the difference between storing an object and
referencing an object in a linked list makes a difference here.

In your preferred method, the objects are stored in an external
location from the list and referenced using pointers in the list
nodes. The objects still need to be stored somewhere, so the cost is N
+ M where N is the storage for objects and M is the storage for
pointers to the objects.

With the copying method, the list will replace the "external location"
and act as the primary point of storage for the objects. Then if
references are needed beyond the list, pointers can be used. Once
again, the cost is N + M.

The only difference here is swapped roles of storage and reference.
The storage costs are identical if you want one pointer for each
object, so if copying brings the system to it's knees, referencing
will too.

I suspect you're imagining both the external location *and*
interdependent copies stored in the list, which is very likely to be a
flawed design before the implementation details of your list even
enter into the picture.
 
K

Keith Thompson

Kelsey Bjarnason said:
Keith Thompson said:
(e-mail address removed) (Richard Bos) writes: [...]
...because this is nonsense. There have been _many_ situations in
which sizeof(void *) != sizeof (size_t) != sizeof (int).

I don't think I've ever used a system where sizeof(void*) !=
sizeof(size_t).

Yes, but you are on record as never having had to contend with tiny,
small, medium, compact, large and huge memory models. Things could
get... interesting.

Particularly since two pointers which actually point to the same thing
may not compare equal, due to segment:eek:ffset varations.

At least huge pointers normalized. :)

(It is *so* nice not to have to deal with that crap anymore.)

If two pointers that point to the same thing don't compare equal,
then the implementation is non-conforming. C99 6.5.9p6:

Two pointers compare equal if and only if both are null pointers,
both are pointers to the same object [...]

(The "[...]" deals at some length with function pointers and pointers
just past the end of objects.)

I suppose I'm not surprised that a C compiler that deals with the
various memory models might not be completely conforming.
 
C

Chris M. Thomasson

Probably because there's no such construct in portable C. You can
simulate exceptions using standard C, but it gets ugly very quickly.
I don't see how the difference between storing an object and
referencing an object in a linked list makes a difference here.
In your preferred method, the objects are stored in an external
location from the list and referenced using pointers in the list
nodes. The objects still need to be stored somewhere, so the cost is N
+ M where N is the storage for objects and M is the storage for
pointers to the objects.

Humm... I may me misunderstanding you, buy exactly why do the objects need
to be stored elsewhere? I mean, the list already stores a reference to the
object and that's good enough for me. For instance, where am I using extra
storage to "store objects" in the following program:


http://clc.pastebin.com/3ymseiDB


Take note of the for loop comprised of lines 131-141. This is where I create
objects and store references to them (e.g., pointers) in various lists.
Okay, notice how the objects are only being stored within the lists and
nowhere else?


[...]
 

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

Similar Threads

size_t, ssize_t and ptrdiff_t 56
size_t in inttypes.h 4
The problem with size_t 45
return -1 using size_t??? 44
Plauger, size_t and ptrdiff_t 26
size_t and ptr_diff_t 9
size_t 18
finding max value of size_t 22

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,285
Latest member
CryptoTaxxSoftware

Latest Threads

Top