Re: Examples comparing Bl ock Scoped RAII and Context Managers
On 27 November 2025 09:08:14 GMT, "Tim Düsterhus" <tim@bastelstu.be> wrote:
>For me the relevant keyword that indicates that the value is not used directly is not the
>'as', but the 'each' part of the 'foreach'. Just by reading it as a
>English sentence, it becomes clear to me what is happening.
>
>The same is not true for me for using (file_for_write('file.txt') as $fh)
>or even worse using (new Manager() as $notActuallyTheManager) (which is part of the
>RFC).
Hi Tim,
Thanks for your thoughts. I will definitely go over your other email in detail when I have some more
time and energy, and update some of my examples.
Regarding this point, I think it's a really interesting observation, and I wonder if we should
be looking for different keywords that read more clearly. For instance:
using(new SomeManager() for $someResource)
using($someResource from new SomeManager())
context(new SomeManager() giving $someResource)
Regards,
Rowan Tommins
[IMSoP]
Thread (8 messages)