Author: Uri Blass
Date: 02:54:43 05/28/04
Go up one level in this thread
On May 27, 2004 at 20:11:52, Filip Tvrzsky wrote: >On May 27, 2004 at 19:05:42, Uri Blass wrote: > >>On May 27, 2004 at 18:41:59, Randall Shane wrote: >> >>>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. >> >> >>I think it can make this assumption. >>I see no reason to write one printf of 2 strings and to mean different thing >>than the thing that is done by 2 printf. >> >>It is a confusing code. > >Uri, I am sorry, but this is really YOUR fault, not compiler fault. I am also >little bit suprised at your complaints about compiler behaviour knowing your >strictly logical style of thinking. Because when you read language specification >and think thoroughly about it then you should realize that compiler does exactly >what is supposed to do and not what it could assume to be your wish. And thank >God for it! Because I am sick of software which knows better than me what I >want. >Filip In that case it is a mistake in defining the language. I did not read language specification and I simply generalized based on previous experience. I also think that the compiler should at least give a warning in that case because I guess that I am not the first person and not the last person to do that kind of mistake. I guess that in big majority of the cases that programmers write printf("%s %s ",a,b); they mean printf("%s ",a); orintf(" %s ",b); If the expressions are not the same the compiler should at least warn the programmer about it. Uri
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.