Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > self-call vs. g...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 1046 of 1099
Post > Topic >>

self-call vs. goto

by Allan Adler <ara@[EMAIL PROTECTED] > Feb 17, 2008 at 12:05 PM

I finished reading the code for the routine "count" in the C source for
the Go playing program Wally. I downloaded it a long time ago but it
should
be at
http://www.usgo.org/resources/computer.html
I know there are better programs but I'm just doing this for practice and
this
is a fairly small program to study. The routine takes as inputs the
integer
coordinates of a position on the board and also some parameters, one of
which
is a board (i.e. double array of int of a certain size), called "scratch",
which is used to keep track of which positions have been looked at. After
modifying the entry of scratch for the position (x,y), it then examines
the
(up to) 4 adjacent positions and, in each case, if certain conditions are
met,
it runs through the code for that position. Let me be more precise about
that:
for the first 3 of the 4 possible adjacent positions, it runs through the
code
by calling "count" with the same parameters except at this adjacent
position,
but for the 4th it jumps to a label at the beginning of the code for
"count".

So, in all 4 cases, it seems that the behavior is essentially the same.

What I'd like to know is whether there is any reason why it might be
advantageous to use a goto in the 4th case but a self-call in the other
three cases? Would it be better to use the goto in all 4 cases, e.g. due
to some overhead from the function call?
-- 
Ignorantly,
Allan Adler <ara@[EMAIL PROTECTED]
>
* Disclaimer: I am a guest and *not* a member of the MIT CSAIL. My actions
and
* comments do not reflect in any way on MIT. Also, I am nowhere near
Boston.
-- 
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
 -- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line.  Sorry.




 2 Posts in Topic:
self-call vs. goto
Allan Adler <ara@[EMAI  2008-02-17 12:05:00 
Re: self-call vs. goto
gordonb.6drpm@[EMAIL PROT  2008-03-08 12:20:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu May 15 0:40:47 CDT 2008.