Am 29.10.15 um 01:44 schrieb Bob Weinand: >> Am 29.10.2015 um 01:08 schrieb Andrea Faulds <a...@ajf.me>: >> >> Hi everyone, >> >> It’s been two weeks, so voting on this RFC can start. The rules are as >> usual. This is a language change, so a 2/3 majority is required. >> >> The vote can be found here: >> >> https://wiki.php.net/rfc/void_return_type#vote >> >> Voting starts today (2015-10-28) and will end next Sunday (2015-11-08), 10 >> days’ time. >> >> Thanks! >> -- >> Andrea Faulds >> http://ajf.me/ > > Hey Andrea, > In general I like the RFC's idea to have a return type for functions > returning nothing in particular/null. > > I'm just thinking null would be a better choice than void. > After all, you're not being able to use void anywhere else except in context > of single return value. > > In every other case like unions or even returning null by reference (yeah, I > know, but we should consider that case too.), we'll need null. void doesn't > make any sense here. > I prefer to not make the mistake of mixing null and void in return types. > It'll be just inconsistent. > > And aside from that, there's always the logic point that a void function > should return nothing, not null. So, we'd should enforce it, but we can't > really due to dynamic function calls when we want to forward the result etc.. > So, we should declare our functions to return null and not void, because > that's what we really get. > > It's maybe a break with most languages, but returning null, is what is most > suited to PHPs dynamic nature. We shouldn't fixate on void, just because most > languages use it (there are already some exceptions though), but really > choose what fits PHP best. > > Hence -1 on void until we can discuss null too. > > Thanks, > Bob
Hi everyone. In my opinion it's more of a philosophical question whether to return null or void. It's like sending someone of and either expecting them to come back and bring something (might be nothing, hence NULL) or not expecting them to come back at all (hence void). By declaring a return type of "void" that means this function or method is not expected to return AT ALL whereas declaring a return type of NULL means that this function is expected to return, but with nothing in it's hands. Or, put differently: function a() :void {} function b() :null{ return null}; $a = a(); $b = b(); would resolve to $a = $b = null That in PHP $a AND $b contain NULL in the end has nothing to do with the return type of the functions called but with the way PHP handles assignements. But without the void return type declaration we can't even see that the assignment for $a doesn't make sense in the first place. Whether that should be possible at all is then open for a completely different discussion. Just my (probably wrong) 2 cent (and probably too late to the show). Cheers Andreas PS: I'd have voted +1 if I had karma ;) > -- ,,, (o o) +---------------------------------------------------------ooO-(_)-Ooo-+ | Andreas Heigl | | mailto:andr...@heigl.org N 50°22'59.5" E 08°23'58" | | http://andreas.heigl.org http://hei.gl/wiFKy7 | +---------------------------------------------------------------------+ | http://hei.gl/root-ca | +---------------------------------------------------------------------+
smime.p7s
Description: S/MIME Cryptographic Signature