Closed javierfernandes closed 8 years ago
Why not?
Could you explain pros and cons?
I think that the community tries to avoid having a return in a "finally" block http://stackoverflow.com/questions/48088/returning-from-a-finally-block-in-java (the link is broken :()
Because the objective of a "finally" is to release resources, not to implement "domain logic". (Moreover, I think we have it there "just in case" for completitude, I am not sure about teaching it in elementary courses.)
Also we have to think that we can get there from different paths, for example:
try { ... return foo } then always { ... you already returned a value, does
it make sense to override it? }
try { ... } catch e { return bar } then always { ... again a value has been
returned }
try { ... throw exc } then always { ... an exception was thrown and not
cached, you shouldn't mess with return here, catch the exception instead }
I can not think of a good example in which the return in the finally block can not be more gracefully rewritten using try and catch. Can you?
On Mon, Nov 16, 2015 at 9:40 AM, javierfernandes notifications@github.com wrote:
I think that the community tries to avoid having a return in a "finally" block
http://stackoverflow.com/questions/48088/returning-from-a-finally-block-in-java (the link is broken :()
— Reply to this email directly or view it on GitHub https://github.com/uqbar-project/wollok/issues/423#issuecomment-157015637 .
Given that there was no discussion after more than one month I think I can close it.
Yeah, but the question now is if we must add an static check to forbid using return in "then always". I think that today it will let you
Y would forbid it, I can't think of a good example. Can you?
On Tue, Dec 29, 2015 at 9:53 AM, javierfernandes notifications@github.com wrote:
Yeah, but the question now is if we must add an static check to forbid using return in "then always". I think that today it will let you
— Reply to this email directly or view it on GitHub https://github.com/uqbar-project/wollok/issues/423#issuecomment-167782935 .
I am not sure but I might vote for not allowing them.
On Sun, Nov 15, 2015 at 9:02 PM, javierfernandes notifications@github.com wrote: