Is there some sort of common practice about where to return from a function?
I've got this vague recollection of not returning from just anyway. ie

for(foo)
 if(test1)
  return false
 else if(test2)
  return false
return true

against

valid = true
for(foo)
 if(test1)
  valid = false
 else if(test2)
  valid = false
if(valid)
 return true
else
 return false

Same with exiting a program, I take it it's better to do something like

if(!foo())
 exit(1)

as apposed to exiting from within foo?
_______________________________________________
coders mailing list
[email protected]
http://lists.slug.org.au/listinfo/coders

Reply via email to