Loop Labels in Design Philosophy
|
|
What are everyones thoughts on using labels for loops and breaking/continuing using those labels? I know that goto is stayed away from (afaik because most people don't know how to use it properly). Is the same animosity attached to loop labels?
Here's an example of where I'm using it in some code...
DIR_LOOP: for(d in L) t = get_step(src, d) if(isturf(src) && t && !istype(t, type)) new_edge(d)
else if(t && !istype(t, type)) for(var/atom/a in t) if(istype(a,type)) continue DIR_LOOP else new_edge(d)
|
|
In the code you have there, replacing "continue DIR_LOOP" with "break" would have the same effect (assuming there's not more code following that). Even if there is more code, you can do something like this:
Personally, I don't like loop labels because they look strange (you're never expecting to see them) and they require extra indentation.