Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126063 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 qa.php.net (Postfix) with ESMTPS id 5B2521A00BD for ; Tue, 26 Nov 2024 17:51:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1732643272; bh=OTc2Tv/NM0Xh0EmE+MEw45cyXJp1UDHUoiJ8068ovGI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=CxIAfr91MmjHv2LO16BooCQU4/STJcEHwukUzQx0ZADLGqYZVfloiFdyoEaR/Q5zV 6SCqluRZ4PKMrCyo4nxnUXbfnU92LEpuB2dbWVyHanvHW+Jm9or5VvgOeoJn8QF7/s w36Y0EvWLemp092od5UUACFE4VzCmmy1NkkZVCcZYD4zLreyuR0nA/D2eZcKMeD53g 6C9V/TLXiXrmn1ZzLODDyUMGgou6FvPrQiwy9RR51NkGw/Gljl2GFnCTOwGMgJBfJN nps705xU17B2rVeKrnSJP64yfuyqMYXuurHQaw38QnRQN4hacqRYZ4NCD2dzt13RCJ BD37to/VtUj5A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E6104180062 for ; Tue, 26 Nov 2024 17:47:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) 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,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (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, 26 Nov 2024 17:47:51 +0000 (UTC) Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-71d4d219668so294794a34.2 for ; Tue, 26 Nov 2024 09:51:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732643461; x=1733248261; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=OTc2Tv/NM0Xh0EmE+MEw45cyXJp1UDHUoiJ8068ovGI=; b=ZwuUAOG75WShKdUrhLckhAO86lzMhas8zKXul4ryDsPfqpQ25AdPOP6JGuARb4jfMq j0K7ShdoO1XPVmGklKZdSW39MR4XcIUAmrew1VSb2V52W8d4NOoL+ZChAMmrarDhG/F0 PoLVfqRwWtsGU8lxj/5btqaH6qD+vCetH06sR80vebrKLUdSvxLGOMlS/g7tfP3xgAnb RHFxz9scqDildO6FISptb068vED4DIdhuL45OMdZZ5sOqDJkBaN+WgFG3eqF40+2Jskc X9VAt+/KCgdJfLmyISTCTwGth2acBQoW4W0gP+oEgLj7dTDIvQwe1IRxgFdBCxUTfsxO N9Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732643461; x=1733248261; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OTc2Tv/NM0Xh0EmE+MEw45cyXJp1UDHUoiJ8068ovGI=; b=EhcR6qGUkV+9m6ewArVqK1k7B/gYgX0j5rWD6IH4xAsUKtPpyCWw883yj3TyR7f6I+ sLxGvOBjb64Y/T1qY1Exjbf3OU/l/Bx+W1W23f3OVC2gSf0JnY71S4gsv/usJbNAu17s 18oPFsa4Xcgo5x+IlTYjHGvACVqPv0URYdRjHPVVHBiUZfGTx8P6LkyKpeRaquqfy6Sj rLeLYZxGbm98ZVUDCkc77GSBufmm66dTcoEBnX3GxPGUBOBrO3jnwkl10/fgQM1zjHbI LtwieFWAvIe66rpAVGCD7eX6oRZSx0xfaFP6yKdGq6lLSxsLbUGkBwn21Aj6CWQEaJU1 3GHg== X-Forwarded-Encrypted: i=1; AJvYcCXGsJmLxgNw0l0OSCKOS6OwEn/Zwh+WxS7AMfbppfMZeba6ocfh66UOZogQodOBCTNYannXqe5JsvM=@lists.php.net X-Gm-Message-State: AOJu0YznscExfTmSTQIt2nCP+iQvQn0QxR5w9f7OrhZquiMG/PUCwHrl 3hBwYhiF/RvpLSH1A26aLUbiX+ZvuUxrW/kbmpPXYSPJ9pqtPuN7+NVYpQCvrmedx+mYcwxSXDs fb+nQWRpbwnA9lXD1joYcDYg0TPcVvYsz X-Gm-Gg: ASbGncvUef+0chu9ww2M3SeRUe/sAMMvtyXdYAqnXThoK7ybK90tfc4TybS6NXmF+Oa gXr1VI9qzHmv35OSgJERmKNXAiw0GWFbq5jrz7wzNMky4RQ5yPndrslFvZTHiYNpp X-Google-Smtp-Source: AGHT+IEUJkMhYnNtQc4cSP2Dm5G8qC8qGFobGcdTuDYqdEIaLZJogUR+gOv2Q9fJWpmtB/4g1gNZxGR+uBnwNt+wRrI= X-Received: by 2002:a05:6830:2707:b0:718:83f7:9875 with SMTP id 46e09a7af769-71d59558747mr1132414a34.1.1732643461281; Tue, 26 Nov 2024 09:51:01 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <99f8520a-e8ba-471c-bcdb-6f305089c66b@gmx.de> In-Reply-To: <99f8520a-e8ba-471c-bcdb-6f305089c66b@gmx.de> Date: Tue, 26 Nov 2024 14:50:25 -0300 Message-ID: Subject: Re: [PHP-DEV] Return When To: "Christoph M. Becker" Cc: Volodymyr Volynets , internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000000846820627d47e7d" From: deleugyn@gmail.com (Deleu) --0000000000000846820627d47e7d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Nov 26, 2024 at 2:18=E2=80=AFPM Christoph M. Becker wrote: > What's wrong with > > if (!$result['success']) return $result; > > Christoph > I don't think I'm in favour of the proposal as I think it's high effort for little gain, but to me this "alternative" requires you to mentally parse a conditional statement and then pay attention to its consequence, which is an afterthought and can be a return, but can also be anything else. The proposed syntax seems superior because the first thing the developer is presented with is the fact that this is a return statement / end of the block, but under a specific condition, which is a secondary artifact. Working with early returns and fail-early approaches, I have to agree that the proposed syntax is superior than this alternative and not just because of current coding standards, but more on the semantics of how to go about the statement itself. But as I stated, it doesn't feel like the effort is worth the benefit because even if this could be implemented in a 1-line-of-code on php-src, it still means syntax change which will affect tooling and cause a ton of open-source overhead with token_get_all() changes, etc. --=20 Marco Deleu --0000000000000846820627d47e7d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, Nov 26, 2024 at 2:18=E2=80=AF= PM Christoph M. Becker <cmbecker69@= gmx.de> wrote:
What's wrong with

if (!$result['success']) return $result;

Christoph

I don't think I= 9;m in favour of the proposal as I think it's high effort for little ga= in, but to me this "alternative" requires you to mentally parse a= conditional statement and then pay attention to its consequence, which is = an afterthought and can be a return, but can also be anything else. The pro= posed syntax seems superior because the first thing the developer is presen= ted with is the fact that this is a return statement / end of the block, bu= t under a specific condition, which is a secondary artifact.

=
Working with early returns and fail-early approaches, I have to = agree that the proposed syntax is superior than this alternative and not ju= st because of current coding standards, but more on the semantics of how to= go about the statement itself.

But as I stated, i= t doesn't feel like the effort is worth the benefit because even if thi= s could be implemented in a 1-line-of-code on php-src, it still means synta= x change which will affect tooling and cause a ton of open-source overhead = with token_get_all() changes, etc.

--
Marco Deleu
<= /div>
--0000000000000846820627d47e7d--