[php-src] PR #17677: feat: single expression functions
| From: | xepozz | Date: | Mon, 03 Feb 2025 08:17:48 +0000 |
| Subject: | [php-src] PR #17677: feat: single expression functions | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-30639@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/17677
Author: xepozz
I'd like to introduce single expression function declarations, as long as Kotlin has: https://kotlinlang.org/docs/functions.html#single-expression-functions
Example: https://pl.kotl.in/u_4w9vJmj
SEF supports expressions, but seems like statements are also supported in some limited way.
E.g.
fun statement2() = a = 2 cause error.
I'd support statements in PHP as well, cause there are no difference between returning
NULL or a result of expression.
I'd ask for help how to implement short functions always return expression result. I think I
need to create a new ast node like short declaration does and implement logic, or it's better
to reuse short declaration logic?