Re: Draft RFC: foreach iteration of keys without values

From: Date: Thu, 03 Sep 2020 08:27:37 +0000
Subject: Re: Draft RFC: foreach iteration of keys without values
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-111807@lists.php.net to get a copy of this message
Von meinem iPhone gesendet > Am 03.09.2020 um 09:39 schrieb Brent Roose <brendt@stitcher.io>: > > Hi all > > I want to point out the use-case when you're using CS tools, static analysers and IDEs: > they report unused variables as errors. There are ways around those errors, but it's more > convenient if there's language support. I'd say that conceptually it's also more > correct: if you're not using a variable, it shouldn't be there. > These tools all work with documentation conventions already, it would be much easier they standardise on $_ to allow being unused instead of changing the language. > As some of you have shown, there are ways achieve the same result without adding new syntax. > Just like we didn't need short closures and keep using the normal closure syntax, like we could > write if statements and didn't need the nullsafe operator, like we didn't need named > arguments or constructor property promotion. I think the past years of PHP devlopment have shown > that the majority likes convenient langague syntax and constructs, not because it's absolutely > necessary, but because it's just a little more clean, a little less verbose, a bit more > convenient. > > PHP has been maturing over the last years, which means there's room, and need, for things > that aren't strictly necessary. > > Kind regards > Brent > >> On 3 Sep 2020, at 09:18, Stanislav Malyshev <smalyshev@gmail.com> wrote: >> >> Hi! >> >>> If it adds a micro-optimization, great, but allowing a developer to >>> explicitly signal intent is the primary argument for adding void. >>> IMO. >> >> You can signal intent by using $_ or $dummy or whatever. You don't need >> new language construct each time for each way of using or not using a >> variable. >> >> -- >> Stas Malyshev >> smalyshev@gmail.com >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: https://www.php.net/unsub.php >> >

« previous php.internals (#111807) next »