[Gambas-user] Finally/Catch and Return: How is that meant to be used?
martin.fischer6 at web.de
Thu Sep 14 23:12:19 CEST 2023
> I understand your point. You could have complained!
I never complain about things I get for free :-)
> I see two reasons why it works like that...
> The first one is that I tried to minimize the distance between the
> syntax of the language and what is really done by the interpreter.
> If I have to make Finally always run when the function exists, it must
> be implemented by a subroutine behind the hood, so that it can be called
> from any place in the function.
> The other reason is lazyness.
I understand your reasoning, but would still prefer "completeness of
> In other word, it's not actually such a big deal as every local object
> or string is always released at the end of the function, whatever happens.
> The problem only comes when you allocate something that must be released
> manually. I'm thinking about the Alloc() function and database
> But 99% of the time you are supposed to use Gambas objects or strings,
> whose associated ressources are automatically released.
Good point. The example that I was working on actually made native
calls, which means Alloc's and Free's in the Finally block...
By the way: what about file streams? I would expect that these streams
have to be closed as soon as possible and reliably, e.g in a Finally
block in the method that opened it. Right?
Good night for today,
More information about the User