Hi Rowan, Rowan Collins wrote:
I can see the point in denying the right to say "return some_function_expected_to_return_null();" But in a sense this is no different from declaring that a function returns int, and then writing "return some_function_expected_to_return_int();"If a void function can be used in an expression, it can be used in a return expression, and if so, it feels natural for the type hint to propagate: function foo(): void { do_something(); } function wrapped_foo(): void { do_something_else(); return foo(); } // ERROR: can't specify return value in a void function "return foo()" is not illegal because foo is declared void, but because wrapped_foo is - even though the result is exactly as expected.
Hmm, this is an interesting case you've pointed out. Being able to do `return some_other_void_function();` is something I've desired in other languages.
But what if that void function you're calling later adds a return value? Now the calling function is returning a value other than null, violating its type hint and producing a runtime error.
It's a shame there's no "tail call this other function and discard its result" construct.
Thanks. -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
