From: spinoza1111 on
On Apr 25, 2:39 am, Seebs <usenet-nos...(a)seebs.net> wrote:
> On 2010-04-24, Nick Keighley <nick_keighley_nos...(a)hotmail.com> wrote:
>
> > I'm pretty sure the original code was mine.
>
> Don't think so -- he jumped on this in pseudo, where it's been there
> for months.

Bugs and all...
>
> > It's made up code to
> > illustrate that C doesn't have any other way to use the same code to
> > process multiple items. Except duplicating the code which I regard as
> > an even greater sin. This idiom makes it plain that ACKs and NAKs
> > haven't simply been forgotten.
>
> Exactly.  The real key point is that, in his initial "analysis", Nilges
> got his explanation of what the code does *completely wrong*.  He claimed
> that those two cases had no code and didn't do anything, and that this
> should have been commented.

That's what the code looks to a professional programmer. Sure, I was
aware that C has fallthrough: but as an excellent programmer, I never
use it. You need to start writing code for professional and excellent
programmers.

>
> You see what happens next; he didn't know about fallthrough in C's switch

Actually, I did, but never used it.

> statement.  That could make him look bad.  The only way out is to declare

I think you are the one who is concerned with how your look,

> that the thing which could make him look bad is so awful that it should
> never have been used.
>
> > hence the comment... Though the idiom is so widespread I don't think
> > it's really necessary.
>
> It's not if we assume a reader who knows C.  However, in something I'm
> distributing as open source, I prefer not to make assumptions.
>
> There are limits, though -- I don't mind commenting switches with
> "fallthrough" because occasionally people just plain forget that, or
> get distracted by the layout.  In general, though, I am gonna write code
> that's reasonably clear, and following the advice Nilges gives does not
> produce reasonably clear code, as witness the fact that his style leaves
> him spending days working on simple problems.

No, I just trouble to write good code, on a half hour ferry ride,
having a real job as opposed to a corporate programming job which
constitutes welfare for fat white males. Let's see, you took two
months to produce code with these problems (your bad switch()
statements aside):

1. Uninitialized db_header
2. Two calls on either side of an else to the same routine with the
parameters out of order

Sure, you produced an off by one strlen fast. Wow.




>
> -s
> --
> Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...(a)seebs.nethttp://www.seebs.net/log/<-- lawsuits, religion, and funny pictureshttp://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!

From: Patrick Scheible on
spinoza1111 <spinoza1111(a)yahoo.com> writes:

> That's what the code looks to a professional programmer.

No, that's what the code looks like to a programmer who's a bit green
or rusty on C and doesn't pick up on its idioms.

"Professional programmer" is a meaningless phrase as there is no
professional certification comparable to doctors or lawyers.

-- Patrick
From: Seebs on
On 2010-04-25, Patrick Scheible <kkt(a)zipcon.net> wrote:
> spinoza1111 <spinoza1111(a)yahoo.com> writes:
>> That's what the code looks to a professional programmer.

> No, that's what the code looks like to a programmer who's a bit green
> or rusty on C and doesn't pick up on its idioms.

Pretty much.

> "Professional programmer" is a meaningless phrase as there is no
> professional certification comparable to doctors or lawyers.

I don't think that's the key distinction. There's no professional
certification for many fields, but it is quite possible to distinguish
between professionals and amateurs in most.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Jennifer Usher on


"Patrick Scheible" <kkt(a)zipcon.net> wrote in message
news:w9zoch8rn7p.fsf(a)zipcon.net...

> "Professional programmer" is a meaningless phrase as there is no
> professional certification comparable to doctors or lawyers.

This is true. But in many cases, self-taught programmers can run rings
around those with degrees, especially those with two year degrees from
community colleges.

--
Jennifer Usher

From: blmblm on
In article <09b14a6e-23bb-4fc0-8d66-1e7164746293(a)h16g2000prf.googlegroups.com>,
spinoza1111 <spinoza1111(a)yahoo.com> wrote:
> On Apr 24, 8:26 pm, Nick Keighley <nick_keighley_nos...(a)hotmail.com>
> wrote:
> > On 24 Apr, 07:39,spinoza1111<spinoza1...(a)yahoo.com> wrote:
> >
> > > On Mar 21, 2:17 am, Seebs <usenet-nos...(a)seebs.net> wrote:

[ snip ]

> > > >http://github.com/wrpseudo/pseudo

[ snip ]

> > > switch (msg->op) {
> > > case OP_FCHOWN: /* FALLTHROUGH */
> > > case OP_FCHMOD: /* FALLTHROUGH */
> > > case OP_FSTAT:
> > > prefer_ino = 1;
> > > pseudo_debug(2, "%s %llu [%s]: ", pseudo_op_name(msg->op),
> > > (unsigned long long) msg->ino,
> > > msg->pathlen ? msg->path : "no path");
> > > break;
> > > default:
> > > pseudo_debug(2, "%s %s [%llu]: ", pseudo_op_name(msg->op),
> > > msg->pathlen ? msg->path : "no path",
> > > (unsigned long long) msg->ino);
> > > break;
> > > }
> >
> > > Here's the same somewhat cleaned up practice, but here you should have
> > > defined the assignment of prefer_ino, the pseudo_debug and the break
> > > as a macro. Better yet you should have used an OR statement.
> >
> > could you illustrate the use of an OR statement with an example?
>
> Sure: and this rewrite indicates something even probably more horrible
> and less professional about this code
>
> It is that despite the fact that you or Peter claim to want to use
> switch with fall thru "to avoid repeated code" (which ignores a basic
> form of abstraction), your switch statement has repeated code!
>
> The two calls to pseudo_debug2 do the same thing, and one of them
> appears to get the parameters out of order! After two months work,
> this is unacceptable and makes a sick joke out of Peter's libel of
> Schildt.
>
> if (msg->op == OP_FCHOWN || msg_op == OP_FCHMOD || msg_op == FSTAT).
> prefer_ino = 1;
> pseudo_debug(2, "%s %llu [%s]: ", pseudo_op_name(msg->op),
> (unsigned long long) msg->ino,
> msg->pathlen ? msg->path : "no path"); //
> If this, indeed, is the right order
>
> Even if it is possible to call pseudo_debug in one case with an
> unsigned 64 bit second parameter, and a string in the other, if for
> some reason the code in pseudo_debug supports this polymorphism, it is
> simply unacceptable.

To me it seems likeliest that pseudo_debug is a variadic(?) function,
taking arguments similar to those passed to fprintf. That second
parameter looks very much like a printf-style format string, and the
remaining parameters seem to me to match up fine with its conversion
specifiers.

--
B. L. Massingill
ObDisclaimer: I don't speak for my employers; they return the favor.