Write RETURN in the end of subroutines, returning nothing

Link to this posting

Postby Ursego » 21 Feb 2013, 15:34

Always end subroutines, returning nothing (like stored procedures - in contrast to stored functions - and void methods) with return instruction.

Compilers don't force us to write return as the last statement of subroutines which return nothing, but it can be pretty useful in debugging if the last executable construction of the function enables program flow to go inside it or to jump over it (for example, if the script's LAST construction is an if, switch or a loop). If that construction is skipped by the program flow (let's say, doesn't go inside an if) then the debugger's cursor will stop on the discussed return, so you have a chance to do something before the method has been exited. Don't analyze if the final return can be useful or not, simply write it in the end of EACH subroutine - that will never do any harm. It was a requirement in one of companies I has worked for!
User avatar
Site Admin
Posts: 131
Joined: 19 Feb 2013, 20:33

IF you want to ((lose weight) OR (have unbelievable (brain function AND mental clarity))) THEN click:

free counters

eXTReMe Tracker