remember kids...

Aug 04, 2005 14:19

when doing functional programming that any code aftera return statement WILL NOT be executed.

Addendum: += is not a post operator like I thought. Just curious, was I the only person that thought that?

coding tips

Leave a comment

Comments 5

arichi August 4 2005, 15:08:02 UTC
What functional programming language are you using that has explicit return statements?

Reply

evox3 August 4 2005, 15:14:47 UTC
And if you meant procedural, what compiler doesn't spit out unreachable statement problems?

Reply

clayemore August 4 2005, 15:19:42 UTC
it isn't unreachable....
boolean function OnKey
{
switch (key)
{
case:

return true
case:
x+=2;
return true
}
a(x)
return false;
}

See the response to arichi as to why it is set up that way.

Reply

clayemore August 4 2005, 15:16:47 UTC
C++

For some reason the moron that wrote the engine has a convention of using returns instead of breaks...and since the function is a boolean, I thought it easier to just follow that instead of setting a flag and returning the appropriate boolean from inside the switch. I put an update function outside of the switch, and the code never saw it because of the returns inside of the switch.

Reply


Leave a comment

Up