Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: bugs, Bugs and BUGS!

Author: Randall Shane

Date: 15:41:59 05/27/04

Go up one level in this thread


On May 27, 2004 at 18:10:47, Uri Blass wrote:
<snippage>
>
>I do not get the same move twice when I have
>printf("%s ",move_str(0));
>printf("%s ",move_str(1));
>
>I thought that
>printf("%s %s ",move_str(0),move_str(1));
>should be exactly the same instruction.
>
>I understand now that it is not and the second printf does not print move_str(1)
>immediatly after it calculates it but calculates also move_str(0) and change the
>value of move_str(1) by doing it.
>
>I think that it is a bug in the language or in the compiler because it is clear
>that the programmer mean the same in both cases.
>
>
>correct compiler can solve the problem by translating
>
>printf("%s %s ",move_str(0),move_str(1));
>to
>printf("%s ",move_str(0));
>printf("%s ",move_str(1));
>
>I see no logical reason not to translate it in that way from human point of
>view.

Ah, but how is the compiler supposed to know that you didn't mean to overwrite
the array, which is defined internal to your move_str routine?  Without
extensive and deep analysis of the routines, it can't make that assumption.
Even then, how is it supposed to know that you really wanted two separate
strings?  Maybe you wanted the behavior you got -- it can't know that.

A language like C which gives you access to the lowest level constructs (direct
memory access) confers greater responsibility on the programmer when they are
used.

Computer languages have strictly defined syntax and semantics because computers
aren't as smart as humans.  Unfortunately, they don't do what you want them to
do, only what you tell them to do.




This page took 0.01 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.