Hi Robert, > On 14 Feb 2015, at 21:23, Robert Stoll <p...@tutteli.ch> wrote: > > I think a void type for PHP would make sense but only if the return value of > such a function cannot be used.
Why? If the return value cannot be used, it prevents the function being used with any API that stores the return value of a callback. That’s not terribly nice. A void return value doesn’t need to enforce anything on the caller. PHP has always filled in missing values with NULLs, including return values, like other dynamic languages do here. > Otherwise it is another reason for people to laugh at PHP and justifiably so, > telling that a function does not return anything but return null is very > inconsistent. It does implicitly return NULL, but NULL is a useless value, and it’s returned implicitly, rather than explicitly. I don’t think it’s really that ludicrous. > I suggest to use one of the following behaviours: > 1. declaring a function void does not return anything (hence is like echo to > a certain agree) That makes it cease to be a function in the PHP sense. PHP always allows functions to be used in expressions. > 2. declaring a function void does return a thing of type void (that would be > similar to Unit in scala) We don’t need another form of NULL. Also, a thing of type void could be passed around, just as the unit type can be in other languages, so it wouldn’t do what you want it to. > 3. instead of void a function can be declared to be of type null -> almost > the same behaviour as your RFC but without the inconsistency That seems like a strange solution. You’re requiring the function to always return a useless value. -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php