Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111816 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 95825 invoked from network); 3 Sep 2020 14:02:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Sep 2020 14:02:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D7A1C180088 for ; Thu, 3 Sep 2020 06:08:07 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 3 Sep 2020 06:08:07 -0700 (PDT) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id C9C175C0105 for ; Thu, 3 Sep 2020 09:08:05 -0400 (EDT) Received: from imap26 ([10.202.2.76]) by compute7.internal (MEProxy); Thu, 03 Sep 2020 09:08:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=N5ZNCt TysLIKi5LI0mGuGiY+HWmBBsgPwlwRJ3mZgLg=; b=IrDT1ayD+nByQA2CayYi1b 7Gr9QzhkVdc8kPFiN/KSpS8OLI6VcB+tgPPMpUvvD/m/o3UFcmi9IDEAcy968jC4 FkzCTm9//qspbK/J8C7w0q1dwo9zpqLEadhMlu9Ujfc4LVyPOWaqCynso9O8nEg4 Xvq0oAbhAHtcz7+3zCCq6qd/a2ssrDc+KOf9XwlowayY8h63xNJ1ETO1xUoO5fVy DjiIwf+EGAQ5iGSV/vYZVw28XmOiR7VwRhgtt2xQR109R87X/J81GfxcUdGfz+q7 GmrffGZKKCydkBaOZUS/hijlu1CbrbRq3EuWk4NNxRlXadeVA6K94WSbT+fLn48Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudeguddgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 5E8641420488; Thu, 3 Sep 2020 09:08:05 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-259-g88fbbfa-fm-20200903.003-g88fbbfa3 Mime-Version: 1.0 Message-ID: In-Reply-To: References: <89FF9360-609A-439F-BDBE-B3B4C141E00F@newclarity.net> <95eddd89-9915-14fc-7649-9de0e8dd349d@gmail.com> <306f190e-efd8-0db8-a9c3-aff3c90aa1c6@gmail.com> <53FF7328-F05C-496E-8F57-5A81B899CED1@stitcher.io> Date: Thu, 03 Sep 2020 08:07:44 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Draft RFC: foreach iteration of keys without values From: larry@garfieldtech.com ("Larry Garfield") On Thu, Sep 3, 2020, at 3:25 AM, Nikita Popov wrote: > On Thu, Sep 3, 2020 at 10:19 AM Dik Takken wrote: > > > On 03-09-2020 09:38, Brent Roose wrote: > > > 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. > > > > Exactly this. > > > > The intent of a particular language construct does not only need to be > > clear to human readers but also to machines. More explicit intent leads > > to stronger static code analysis tools, which helps us catch more bugs > > earlier. > > > > Regards, > > Dik Takken > > > > Static analysis tools don't need a language feature to support this. They > can recognize the $_ pattern and not emit an unused variable warning for > it. I'd suggest submitting a feature request. > > Nikita I agree here. _ is already a common pattern in other languages for a placeholder ignored variable. It's not a big jump for PHP static analyzers to start ignoring unused $_ variables, and it requires no language changes or formal standards. I am skeptical of any performance difference, but from a reader-communication point of view a de facto convention of $_ == unused, and analyzers recognizing that, seems like the path of least resistance. --Larry Garfield