Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130630 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 5E16C1A00BC for ; Tue, 14 Apr 2026 13:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1776174800; bh=UddkGvvWMuI4VVEAcTBXY0Qd+N3rvmCxN3vJmvHvD0w=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=aKGvp3oF3gL8c+vyZhXglJewXchpRXKPHxuOF/4SS/16PNQpjLR6MndY1DYKnI/bk zqshalfuwLlCEchMZ3B4qCqte0O/A0C3b0b0xCvK4lDueWTLB74At+yZheDDW3JSsQ c+twxBfX0wS+caB1cy7+rDmuG6sOZTOIv1ieQLVSXYgg5NcDT0OiqyOUeHZcjXhPbw MuQw5aaKRXu9AwlI+B1atqSvijkp6fYMERTX7QVOz9rVjimTHBvNfXdCbJPrNe7/YO nsn1uWmPwoMNf/DCZE5vsppE+88lOlcOdalHLTWTHVB2LYJyOu9+HLiZekSqIBC3X8 kJtFtLfa17Fiw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5AA52180053 for ; Tue, 14 Apr 2026 13:53:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 14 Apr 2026 13:53:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1776174793; bh=GkldTEQ/die6CYGErmh2+XUyAWPrhevmk/Jdu6Z65K0=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=mucOXsi4ayBzilKb9qZtKX+MEcKiEBubYXf+g9ZHfrBq16c9UTuJK1IVMsVRcmmsG 7jcbjUi6xCeHJkMtNSD555YlLjD+fuF1f1HLNJU2jGjkpMB87SUBruaTs74vfA+zZI QNf6UY8npm73ZNyCkG2wLpgl42QNdmj+/RCYBXi5c1Ry/AGf6MJKJHGqW3lj4i0vUE PpGBDFBegG16kU+rIw2ASaE0avr/ionCj/Stzu67tjv5rVNfDQQl/FwpLq+HoKEtBQ G9KwzsL17BtNY4r0AWEsUheJke4aPIRIw5IIS1eklOyet0hINpbnedrzVYUJ/TI22x 0rDYEnc4hLPwg== Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Tue, 14 Apr 2026 15:53:12 +0200 To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] Context Managers In-Reply-To: <0c59c7d4-8748-47ca-a626-179661803b51@rwec.co.uk> References: <5d96fca3ca5418e6e9e5d8871b26477f@bastelstu.be> <8bf1b0a7-7771-4f81-b92c-49bb019f7f9d@app.fastmail.com> <02dbe23bb5a4e53be7bf2db7506e07b6@bastelstu.be> <841b8e97-9052-4868-badc-1dd1dad0e99a@app.fastmail.com> <0c59c7d4-8748-47ca-a626-179661803b51@rwec.co.uk> Message-ID: <7ef9efa17addc95c9a63b2e90a15f715@bastelstu.be> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2026-04-08 00:27, schrieb Rowan Tommins [IMSoP]: > Personally, I'm leaning towards option 1 - the case for "break" feels > weak to me. I agree here. For the example use case that is provided in the RFC, I feel that the `break;` is making intent much less clear. When dropping the comment that makes sense in the context of an RFC, but not inside a program, we have. using(file_open('records.csv', 'rw') => $fp) { while ($line = fgetcsv($fp) { if ($line[0] === $record['id']) { break 2; } } fputcsv($fp, $record); } And here I'm wondering what the “high-level” purpose of that `break;` is. I would either need to add a comment: using(file_open('records.csv', 'rw') => $fp) { while ($line = fgetcsv($fp) { if ($line[0] === $record['id']) { // If the record already exists, we are done with processing the file. break 2; } } fputcsv($fp, $record); } or I can just use a self-explanatory variable: using(file_open('records.csv', 'rw') => $fp) { $found = false; while ($line = fgetcsv($fp) { if ($line[0] === $record['id']) { $found = true; break; } } if (!$found) { fputcsv($fp, $record); } } Using a variable is also more easily extendible to a “if found then X else Y” situation. A goto would also be clearer in intent, because I can give it a name and thus it effectively serves the purpose of a simplified comment. It's also easy to find where the control flow jumps by scanning for the label, without need to manually count control structures (which is particularly complicated when not all of them use braces). In fact jumping out of multiple control structures is explicitly documented as one use case on the `goto` documentation at https://www.php.net/manual/en/control-structures.goto.php: > […] a common use is to use a goto in place of a multi-level break. Insofar I don't see how the RFC's claim of “goto is generally discouraged, as it is less structured than break or continue” is backed up by evidence. using(file_open('records.csv', 'rw') => $fp) { while ($line = fgetcsv($fp) { if ($line[0] === $record['id']) { goto record_found; } } fputcsv($fp, $record); } record_found: Best regards Tim Düsterhus