Re: [RFC] Void Return Type

From: Date: Sat, 14 Feb 2015 12:26:08 +0000
Subject: Re: [RFC] Void Return Type
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-82681@lists.php.net to get a copy of this message
Hey François, On 14 Feb 2015, at 04:57, François Laupretre <francois@php.net> wrote: > That's a nice addition and a beginning to distinguish void from null, as I imagine the > function still returns null. > > Now, what about making void a real zval type ? It would open a lot of possibilities. Unlike > null, conversions from void would raise an error. It would also be rejected as argument input type > but could be used as an output type when arg is passed by ref, it could be the default type for > return_value (huge BC break here) and so on... We could do this, but for the longest time we've made all functions have some return value, even ones which don't explicitly return one (they return NULL). I think it'd be better not to change this. I expect IDEs and such could earn you about it, though. > There's a need for a real 'no value' type different from null, as null has too > many uses. If defined correctly, it can be a powerful addition. If I was to go back to 1994, I'd add "undefined" to PHP like JS has. Today, though, I think that is unrealistic, as much as I wish it wasn't. A void type only really makes sense as a pseudo-type for return type checking purposes, IMO. Thanks.

« previous php.internals (#82681) next »