>> Would be posible for blocks to require a return statement instead of raising >> an error? > >It would be possible for the blocks to return values (though not with >the return keyword). I've created a small prototype a few weeks ago: > >``` >$result = match ($x) { > 0 => { > echo 'Foo'; > echo 'Bar'; > 'Baz' > }, > ... >}; >``` > >https://github.com/php/php-src/compare/master...iluuu1994:block-expression >Heavily inspired by Rust: >https://doc.rust-lang.org/reference/expressions/block-expr.html > >While this would perfectly solve the problem perfectly it feels a >little foreign in PHP. Either way, this is something that can be >discussed an implemented in a separate RFC.
My only concern about blocks is that I fell a bit odd that they can only be used under some circustances. I think I would prefer to simply do not include them for now, and discuss these “block expressions” in another RFC as they seem to be an independent language feature. Regards, Iván Arias.