Skip to content
Prev 65261 / 398521 Next

return from nested function?

On Wed, 2 Mar 2005 12:13:17 +0000, "Jan T. Kim" <jtk at cmp.uea.ac.uk>
wrote :
I'm not suggesting that I would ever use code like this, but if x is
never evaluated then the double return would not happen:
function(x) {
print("f")
g(x, return())
print("end of f")
}
function(x, blastoff) {
   print("g")
   if (x) blastoff
   print("end of g")
}
[1] "f"
[1] "g"
NULL
[1] "f"
[1] "g"
[1] "end of g"
[1] "end of f"

However, this is not a style of programming that I would expect to
last for more than 5 minutes after I published a program using it.
Follow Thomas's advice, and use tryCatch instead.

Duncan Murdoch