On 03/06/2025 18:20, Gina P. Banyard wrote:
On Tuesday, 3 June 2025 at 02:36, Anton Smirnov <sand...@sandfox.me> wrote:

On 02/06/2025 23:50, Rowan Tommins [IMSoP] wrote:

I agree the type hierarchy you describe is weird, but rather than
throwing away the functionality completely, I wonder if we can make it
more consistent:

- Make "no return type declared" and "mixed" equivalent
- Make "void" a sub-type of "null", and therefore a sub-type of "mixed"


I think that null and void are semantically very different so I'd like
to suggest just making void subtype of mixed. This will both keep the
semantic meaning of void and make mixed and undeclared mean the same thing.

You are going to need to expand on why you think those two are semantically 
very different.
PHP does not have the concept of "execution control is returned to the calling 
scope, but no concrete value is returned".
And this is a good thing IMHO, as it means you can always take the result of a 
function.

Basically I agree with Ilija and Tim that functions that "return null" and functions that "return nothing but it's shown as null for historical and compatibility reasons" are different, but I see some value in aligning mixed and undeclared return type behavior.

Moreover, "just making void subtype of mixed" can mean everything and nothing.
Do you mean for void to live on its own island like the int or string types?
Make it a subtype of null like Roman suggested?
Have void be a super type of some weird union of types representing scalars 
int|string|float|bool?
Something else altogether?

this:

> Do you mean for void to live on its own island like the int or string types?

never <- void <- mixed

--
Anton

Reply via email to