Message-ID: <3C9CEC35.8010409@notreally.sympatico.ca>
From: LoneCleric <lonecleric@notreally.sympatico.ca>
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1
X-Accept-Language: en-us
MIME-Version: 1.0
Newsgroups: rec.arts.int-fiction
Subject: Re: [HUGO] Having a Replace problem - help please
References: <pqip9ugubg5snvfvuljnc4oma2qnugik9h@4ax.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 46
Date: Sat, 23 Mar 2002 15:57:25 -0500
NNTP-Posting-Host: 64.230.114.213
X-Complaints-To: abuse@sympatico.ca
X-Trace: news20.bellglobal.com 1016917098 64.230.114.213 (Sat, 23 Mar 2002 15:58:18 EST)
NNTP-Posting-Date: Sat, 23 Mar 2002 15:58:18 EST
Organization: Bell Sympatico
Path: news.duke.edu!newsgate.duke.edu!nntp-out.monmouth.com!newspeer.monmouth.com!news.maxwell.syr.edu!tor-nx1.netcom.ca!news1.tor.metronet.ca!webster!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail
Xref: news.duke.edu rec.arts.int-fiction:102059

Well, the short answer is: labels are evil.

You see, "goto label" won't just move the execution process to wherever
that label is *within the current function* - you can use goto to pretty
much teleport you anywhere in the code, in any function. (That's right,
eeeagh!)

So there's your problem - you're telling the compiler to use a different
Parse instead of the other one it already encountered, and the
compiler's fine with that. But you're also telling it to put a label in
that code when there's already a label with the same name somewhere
else, and it cannot do that. (Because, like I said, labels are global,
not just "within the function".)

I believe Kent has considered changing that, since it's unlikely
somebody would really make use of a goto that would sent you into a
different function. But nevertheless, it's probably better to avoid
labels altogether.

So, as far as you're concerned, you can rename the label in your new
Parse method, as well as in all the gotos in that new Parse, and things
should be fine. But I'd suggest trying a different approach than relying
on gotos, if that's feasible. In my Scavenger Hunt tutorial, I do
something similar when I replace EndGame(). Check it out in v6 of the file.
(And now the plug: The tutorial is still at
http://www.plover.net/~lonecleric/hugo/
but also zipped at
http://www.ifarchive.org/if-archive/programming/hugo/examples/ScavHuntFull.zip

)

Hope this helps,
LC

Dana Clarke wrote:

> I now have my first occasion to "Replace" a routine that is already in
> hubolib.h and am having a small problem.  The routine is Parse (not
> that likely matters) and I copied the routine into my program and am
> calling Replace Parse rather than Routine Parse (having made my minor
> changes to the routine).  However, when I compile, I get an error
> telling me that a label that is contained in the original Parse
> routine (and still in my replacement) is already defined.  Does
> "Replace" not truly replace the entire routine (labels and all) or is
> there something else I must do?

