Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112085 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 1621 invoked from network); 21 Oct 2020 04:51:41 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Oct 2020 04:51:41 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8DC921804AA for ; Tue, 20 Oct 2020 21:08:42 -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=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 20 Oct 2020 21:08:41 -0700 (PDT) Received: by mail-qk1-f180.google.com with SMTP id i22so1077555qkn.9 for ; Tue, 20 Oct 2020 21:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=UCf43jwlPSIdzKN9wivkPFV/yHFPGovCA4ueWyM5g20=; b=C23TEdbP2mn5baMtGdIGFHPHeXRHO1CAbSQpL68+WcuR/GM1+BkDk1YGN0XHVB1M8u 2hkNSlINYeyGm1lNDGv5xEtjePbh+w0OywpKyo5OZDwy/FkSQlIzWTTZQtD8oZU3vm7m 412lUXHjNt6gyVAtBBdLRd7xolKe1Mx/rtNU/c1TaMm5RGUEFH8S9AIbFMQJpu8xp8Ns r/tEVCN+DVBufG63HpWp0pF5fxrldCXDMc+5uH58J4/mglBSccCbaAhyv8sOH1aTlHXe rnZ64Glpz9SU2CoT3xit15Ucbx3doDD+nd47CblGz6kOU+AzihY/9SyIho5C//8NEFuq L79A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=UCf43jwlPSIdzKN9wivkPFV/yHFPGovCA4ueWyM5g20=; b=KqLFX5njFCFmkp2vCmJ8QGuUJvbwSE1thBOFmMfuRX5IUwyxFlZp5E3De1ONsBPZqv pi2P0GCdl3Nf418TtO27JfkNZ9H7hvlwvUd/euQhr1QNvc3hL+VNi5PoXMmsI/Lfoxl6 7RPd6BB9EptxxMbN5qoPyfQv+n6vsfX8ax9KN4qRpTAAJRR393G+FebY4WGZEF1WGI8m Z+wjMXsN+iUgFecVoWqQpGA8AGTW+lAKUMaILCY96Z4HpAVaUqL9eWkvRmeKPkV1FY/l 7l29DXlB5dBVIwCGjy+p0B2fnuayqT/FW/5ktHfxem4Z150okXd39RM2dt9EceFuLhic 7KgQ== X-Gm-Message-State: AOAM5320vUne72vE2PysbvbRCPF8On4Ya9vgo81YCfxDJHtVCSQ/NpU2 bzwTLqIr0Ci1r7r6xwpn6+lLgw== X-Google-Smtp-Source: ABdhPJxCXdMz6nb97qBUZr6IHfKKXrNrIde4KCrpDMWYncdhitTwq0Z4hpwBZ43jEsye36GcaqfzAw== X-Received: by 2002:a05:620a:1250:: with SMTP id a16mr1428874qkl.411.1603253317020; Tue, 20 Oct 2020 21:08:37 -0700 (PDT) Received: from [192.168.1.254] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id h125sm716484qkc.36.2020.10.20.21.08.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2020 21:08:35 -0700 (PDT) Message-ID: <41AA7084-18F3-431B-B135-46C44FC26D1E@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_29739DE6-B4EE-4A4A-8A07-D4E922AFC4A3" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Date: Wed, 21 Oct 2020 00:08:35 -0400 In-Reply-To: Cc: php internals To: Larry Garfield References: X-Mailer: Apple Mail (2.3608.120.23.2.4) Subject: Re: [PHP-DEV] [RFC] Short-function syntax From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_29739DE6-B4EE-4A4A-8A07-D4E922AFC4A3 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Oct 20, 2020, at 2:19 PM, Larry Garfield = wrote: >=20 > A while back, Nikita mentioned that it should now be easy to offer an = abbreviated syntax for functions that are just a single expression. I = decided to take a crack at it and it turns out he was right. I thus = offer this RFC: >=20 > https://wiki.php.net/rfc/short-functions >=20 > Hopefully I made a decent enough case for it. It's entirely a = convenience factor, but I think for many OOP cases (getter methods and = factored out operations) and functional cases (where functions should = generally be a single expression conceptually) it does make the code = nicer, more compact, and more readable. Simple and elegant. I like it. I have two comments, but not about the feature. =20 One comment is about the RFC itself, and the other is about a use-case = used to justify the feature that could warrant its own bespoke feature. 1. The section on "Conditional methods" is really just an argument about = the benefits of encapsulating complex logic into well-named functions as = you could achieve exactly the same benefit with the existing function = syntax. It does not appear to me that it provides any specific = justification for the feature in the RFC. Should it really be part of = the RFC? 2. In the section "Decorating functions in live code" where you state = "Often times, methods exist that are just delegating to some other = method, either in the same object or a composed object." I think we = could see great benefit from explicitly building delegation into classes = much like how Go provides type embedding[1]. For PHP, extending the = syntax for traits could be used to support delegation of one class to = another embedded class. Can you see this as a potential feature? -Mike [1] https://travix.io/type-embedding-in-go-ba40dd4264df --Apple-Mail=_29739DE6-B4EE-4A4A-8A07-D4E922AFC4A3--