Hi, I'm Khaled Alam, a software engineer based in the UAE and a long-time
PHP user. I'd like to request RFC karma to publish an RFC proposing a native
 "*defer"* feature and gather community feedback.

Inspired by Zig's "defer", it schedules a block to run when the current
function exits (return, exception, or natural end), executed in LIFO order,
aimed at safer cleanup without repetitive try/finally scaffolding.

Proof-of-concept implementation PR
<https://github.com/php/php-src/pull/20786>.

Current status:
[x] Parser/AST support for defer { ... }
[x] Compilation + VM support with per-call defer stack (not shared on
op_array)
[x] Defers run correctly on explicit/implicit returns, LIFO order
[_] I’m currently working on exception-unwinding handling so defers also run
when an exception is thrown

Wiki username:
*khaledalamxyz*GitHub username*: *khaledalam

Thank you for considering granting RFC karma.

Best regards,
Khaled Alam

Reply via email to