Re: String reversing problem
slebetman@yahoo .com wrote:[color=blue]
> tmp123 wrote:[color=green]
> > Hi,
> >
> > See inlines:
> >
> > Christian Bau wrote:[color=darkred]
> > > tmp123 wrote:
> > > > To Mr. Christian Bau:
> > > >
> > > > Your English seems not to be the most valid to be used in net, because
> > > > could be easily confused with agressive, specially by non-English
> > > > people. Moreover, it could be taken as a confusion between what is a
> > > > medium to interchange knowledgment, and what is a real programming
> > > > team.
> > >
> > > Nothing wrong with my english. Lots wrong with your code. I don't care
> > > too much about the undefined behavior, because you managed to write
> > > completely incomprehensibl e code for a very simple task.[/color]
> >
> > Code that has been clearly state as "just for fun", that is, as an
> > academic experiment. At least, me, I get new knoledgment about pointer
> > before arrays and sequence points. Thanks to persons who have provided
> > it.[/color]
>
> "For fun" still doesn't make your code correct. You stated that it
> works but the experts here have pointed out that even so it is still
> not correct "C". So that doesn't invalidate Mark's comments - your code
> still is horrible, learn and move on.
>
> As for your comment about Mark's tone being aggressive, you have to
> learn that this is Usenet, and taking on an aggressive tone is a
> tradition of the net long before you showed up. Some groups liks
> comp.lang.tcl may be less aggressive but comp.lang.c is aggressive (I
> learned that the hard way). Maybe it's because so many people keep
> asking the same stupid questions here over and over again (and keep
> making the same stupid mistakes that others have made before).
>[color=green][color=darkred]
> > > void reverse_string (char* s)
> > > {
> > > int i = 0;
> > > int j = strlen (s) - 1;[/color]
> >
> > 1) It is not the same initialize a variable as give a variable the
> > first value it will take.[/color]
>
> What are you trying to say here? That code is correct.
>[color=green]
> > 2) Not always a stack to add variables is available, or to add more
> > variables to it. Sometimes only modify code is allowed (i.e: patching
> > firmware in real time systems without stop them).[/color]
>
> I don't see how this is different from your code since you yourself
> introduce the variable 'r'.
>[color=green]
> > 3) Relation between names "i" and "j" and their meaning/usage is
> > totally lost.[/color]
>
> Lost? I understood it. The code is short and clear so it is
> stylistically correct to use simple variable names (n, x, y, i, j
> etc..). For that matter, the "relation between" 'r' and 's' in your
> code and "their meaning/usage" also fall into the same category.
>[color=green][color=darkred]
> > > while (i < j)[/color]
> >
> > 4) Never heard about "for" statement?. It is used to enclose in an easy
> > to read statement all control of the loop iterators (initialization s,
> > exit condition and state update).[/color]
>
> "Easy to read"? Certainly not your code. And in Mark's code "while" is
> quite natural - use the right tool for the right job.
>[color=green][color=darkred]
> > > {
> > > char tmp = s [i];[/color]
> >
> > 5) Declare char here, far of the semantically parent of it (char *s) it
> > is only a way to hide things. And lots of compilers will ignore it (no
> > new frame).[/color]
>
> This is correct and valid in C99 (unlike your code which is incorrect
> and invalid in any C standard). Just because there are no C99 compilers
> around doesn't mean that this code is not "C".
>[color=green][color=darkred]
> > > s [i] = s [j];
> > > s [j] = tmp;[/color]
> >
> > 6) It seems this code must always be compiled with latest version of
> > advanced compilers. The responsability to convert array index
> > calculations to pointer operations, even integers to pointers, is
> > transferred to compiler.[/color]
>
> Nope, the above fragment of code will compile on any C compiler, I
> suspect it is even valid in the original K&R "C" but I'm not sure.
>[color=green][color=darkred]
> > > works and is easy to understand.[/color]
> >
> > 8) "Works" is not a measure of quality.[/color]
>
> True, as the experts here have pointed out about YOUR code. But "easy
> to understand" IS a measure of quality.
>[color=green]
> > This is my last post in this subject. I don not like to be troll, nor
> > feed trolls.[/color]
>
> Mark have not been acting like a troll. He was merely scolding you for
> writing poor code. You however are increasingly acting in a troll like
> manner by insisting to argue even when you've been proven wrong.[/color]
Oh crap, I thought tmp123 was referring to Mark. I meant Christian.
Sorry for the identity mix-up. My comments still stand though.
slebetman@yahoo .com wrote:[color=blue]
> tmp123 wrote:[color=green]
> > Hi,
> >
> > See inlines:
> >
> > Christian Bau wrote:[color=darkred]
> > > tmp123 wrote:
> > > > To Mr. Christian Bau:
> > > >
> > > > Your English seems not to be the most valid to be used in net, because
> > > > could be easily confused with agressive, specially by non-English
> > > > people. Moreover, it could be taken as a confusion between what is a
> > > > medium to interchange knowledgment, and what is a real programming
> > > > team.
> > >
> > > Nothing wrong with my english. Lots wrong with your code. I don't care
> > > too much about the undefined behavior, because you managed to write
> > > completely incomprehensibl e code for a very simple task.[/color]
> >
> > Code that has been clearly state as "just for fun", that is, as an
> > academic experiment. At least, me, I get new knoledgment about pointer
> > before arrays and sequence points. Thanks to persons who have provided
> > it.[/color]
>
> "For fun" still doesn't make your code correct. You stated that it
> works but the experts here have pointed out that even so it is still
> not correct "C". So that doesn't invalidate Mark's comments - your code
> still is horrible, learn and move on.
>
> As for your comment about Mark's tone being aggressive, you have to
> learn that this is Usenet, and taking on an aggressive tone is a
> tradition of the net long before you showed up. Some groups liks
> comp.lang.tcl may be less aggressive but comp.lang.c is aggressive (I
> learned that the hard way). Maybe it's because so many people keep
> asking the same stupid questions here over and over again (and keep
> making the same stupid mistakes that others have made before).
>[color=green][color=darkred]
> > > void reverse_string (char* s)
> > > {
> > > int i = 0;
> > > int j = strlen (s) - 1;[/color]
> >
> > 1) It is not the same initialize a variable as give a variable the
> > first value it will take.[/color]
>
> What are you trying to say here? That code is correct.
>[color=green]
> > 2) Not always a stack to add variables is available, or to add more
> > variables to it. Sometimes only modify code is allowed (i.e: patching
> > firmware in real time systems without stop them).[/color]
>
> I don't see how this is different from your code since you yourself
> introduce the variable 'r'.
>[color=green]
> > 3) Relation between names "i" and "j" and their meaning/usage is
> > totally lost.[/color]
>
> Lost? I understood it. The code is short and clear so it is
> stylistically correct to use simple variable names (n, x, y, i, j
> etc..). For that matter, the "relation between" 'r' and 's' in your
> code and "their meaning/usage" also fall into the same category.
>[color=green][color=darkred]
> > > while (i < j)[/color]
> >
> > 4) Never heard about "for" statement?. It is used to enclose in an easy
> > to read statement all control of the loop iterators (initialization s,
> > exit condition and state update).[/color]
>
> "Easy to read"? Certainly not your code. And in Mark's code "while" is
> quite natural - use the right tool for the right job.
>[color=green][color=darkred]
> > > {
> > > char tmp = s [i];[/color]
> >
> > 5) Declare char here, far of the semantically parent of it (char *s) it
> > is only a way to hide things. And lots of compilers will ignore it (no
> > new frame).[/color]
>
> This is correct and valid in C99 (unlike your code which is incorrect
> and invalid in any C standard). Just because there are no C99 compilers
> around doesn't mean that this code is not "C".
>[color=green][color=darkred]
> > > s [i] = s [j];
> > > s [j] = tmp;[/color]
> >
> > 6) It seems this code must always be compiled with latest version of
> > advanced compilers. The responsability to convert array index
> > calculations to pointer operations, even integers to pointers, is
> > transferred to compiler.[/color]
>
> Nope, the above fragment of code will compile on any C compiler, I
> suspect it is even valid in the original K&R "C" but I'm not sure.
>[color=green][color=darkred]
> > > works and is easy to understand.[/color]
> >
> > 8) "Works" is not a measure of quality.[/color]
>
> True, as the experts here have pointed out about YOUR code. But "easy
> to understand" IS a measure of quality.
>[color=green]
> > This is my last post in this subject. I don not like to be troll, nor
> > feed trolls.[/color]
>
> Mark have not been acting like a troll. He was merely scolding you for
> writing poor code. You however are increasingly acting in a troll like
> manner by insisting to argue even when you've been proven wrong.[/color]
Oh crap, I thought tmp123 was referring to Mark. I meant Christian.
Sorry for the identity mix-up. My comments still stand though.
Comment