goto = evil? in Design Philosophy
I've been reading some old forum posts about goto being evil and ineffecient.
I'm curious, if it is 'evil' why is it in the DM language? Or does it actually have a useful function?(If so could someone show me an example?)
Because every time you write "goto [tag]," you're going to then have to find the place where you wrote "[tag]" to know what's going on.
I actually use goto in one of my battle systems for a game I am making. I dunno if it is a proper use of it or not, but if anyone wants to see it, feel free to ask...
to is inefficient too.
It's much slower than a normal for() loop.
#define DEBUGmob/verb One() var/i=1 while(i<5000) i++ world<<i Two() var/i=1 Label: i++ world<<i if(i<5000) goto Label: Three() for(var/i=1,i<=5000,i++) world<<i
var/possnamewhile(!src.name) possname=input("Enter Name","Character Creation",src.key) as text if(CheckName(possname)) src.name = possname
I've had one place where I found I needed goto, which is in my character creation, where it goes to another spot when a player makes a mistake in creating the character. Right now I'm trying to find a better way of doing this, because I don't like it as it is right now.
I don't think he was talking about that though. He said "to is ineficient too," which I take to mean the style of for(var/index = 1 to 100)
Chances are, it's not a proper use. As someone else somewhere in this thread said, it's only proper in heavily nested loops, sometimes. The only other place I've seen it is C error handling, and that's because C lacks any other ways to handle errors.
I was talking about the "to" operator. Y'know, I think it's undocumented.
But, yeah, your information was useful. How long did the while() take?
pword var name="secret area" //label password="secret" //password list/allowed=list("androidlore") //keys allowed to see the passwordmob/verb/pwords() var/list/pwords pwords+=new/pword for(var/pword/X in pwords) if(ckey=="androiddata")goto allowed if((ckey in allowed))goto allowed return allowed: src<<X.password