> Firstly, block expressions are a foundational part of the Rust
> language, not a special case used in only one place.

>From a previous e-mail:

> 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:
>
> 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.

We can't do everything at once. The current block syntax is completely
compatible with that suggestion. All we'd have to do is relax the
restriction of only allowing blocks when the result isn't used.

> it makes *all* the control flow blocks in Rust feel more natural to
> developers coming from other languages.

Same thing here. If you don't use the result value, it looks just like
the switch. That's why I'd feel odd to require a semicolon.

> the page you linked calls out an ambiguity caused by omitting the
> semicolon

This code is parsed like this:

```
match($x) { 1 => ['foo', 'bar'] }
[0];
```

* statement list
    * match expr
    * array literal

Note that we can't have ambiguous grammar since Bison would
immediately expose it.

> It then explains the important restriction of only omitting the
> semicolon if the result is void/null rather than a concrete value.

That's true. Unfortunately we don't have this info at compile time.
That's why we throw away the expression result just like with any
other expression statement.

> I would probably vote no to the current proposal

I understand. Everybody is entitled to their opinion. If the vote
fails that doesn't mean we'll just completely give up. I would
reiterate and try again. Sadly, it's very hard to get a feel for how
many people have which opinion through the mailing list.

Ilija

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to