Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113753 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 53899 invoked from network); 25 Mar 2021 03:27:11 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Mar 2021 03:27:11 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 011E41804B7 for ; Wed, 24 Mar 2021 20:23:06 -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=0.8 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MISSING_HEADERS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) (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 ; Wed, 24 Mar 2021 20:23:05 -0700 (PDT) Received: by mail-io1-f44.google.com with SMTP id e8so516413iok.5 for ; Wed, 24 Mar 2021 20:23:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:cc :content-transfer-encoding; bh=QJKCS6eqedibMNa/rbMnQf0cjcL3+2RZYxKF50GMII4=; b=GItgLoMpP6b741hFxMwIx8ARyDJRa5vaaW/entTGGUrcVJXPM9XU+sVsUK8vmhvORw i6eEsCLii+i2W6W4DfeSeIYG/ydBDVRvTWZX7HKQnuerbPSRPbwfC9s5Q8Zyssq3c5l9 OkDoYUx/u2Jd7TYOGtRBxpIGhzKYjVbsDo2nk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:cc:content-transfer-encoding; bh=QJKCS6eqedibMNa/rbMnQf0cjcL3+2RZYxKF50GMII4=; b=CgXtv9kvcC9NRdqXPh/6RQ45vKPDIxkdMbn4Bgk53d/+m4+vCEv8QBLaRJg/ztebHV Z3P8GdKadoLskWVtlPl1al6l1wbBGyu/poEQvWIkpGNxNJH4FUa87rdP/X74YzHBmjmk X4gCuwp7RO0OsU2RLpo84rm/B+Zo+F0mef1qoI3JjUrq4G5d05xDPm8JeyBgHDktBdFw nzuGwjqgSXzEzv798g6QjxJnha+aYxmvAx+OgQsjEB08L4wcJ3vik72Y0Z/ZexcC5CKP U2+40+t75IxrnbRL1QV251SnDCz96vBYR0bHjrCx064+ZxqAkkoQe/ZWHJ29gYD3aB2Y W1Nw== X-Gm-Message-State: AOAM533exAmD0F7+MyKLRXh9NLHpkpDYf4QMDny//nwxUmX81E1POiJt eas6VPvRg/g2+zE6y64gcguWhQrQAUqWYQCdk2ywOkUorNuL7g== X-Google-Smtp-Source: ABdhPJyh2nBqYgIUZr6nrxxJwvpqVFHcnIx5zcbBEtQsaSkdS17jOIp+iyMQyNujQQXmpyPCEfnmhrJHAvs4dPOjfY8= X-Received: by 2002:a05:6602:179c:: with SMTP id y28mr4759594iox.151.1616642583001; Wed, 24 Mar 2021 20:23:03 -0700 (PDT) MIME-Version: 1.0 References: <44ac7866-75ef-44ab-a5f9-4e571652b5e6@www.fastmail.com> <21C66BCC-A77D-48B0-A653-9D65ADF06A3B@newclarity.net> In-Reply-To: <21C66BCC-A77D-48B0-A653-9D65ADF06A3B@newclarity.net> Reply-To: Levi Morrison Date: Wed, 24 Mar 2021 21:22:52 -0600 Message-ID: Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Short functions, take 2 From: internals@lists.php.net ("Levi Morrison via internals") On Wed, Mar 24, 2021 at 8:02 PM Mike Schinkel wrote: > > > On Mar 24, 2021, at 8:39 PM, Larry Garfield wr= ote: > > > > As requested, splitting off the short-functions RFC to its own thread. > > > > https://wiki.php.net/rfc/short-functions > > > > In response to the feedback that the savings in typing volume is small,= that's true but also not the main point. The main point is to allow and e= ncourage functions to be written an in "expression style", that is, as actu= al functions and not procedures. As the RFC notes, such use cases are incr= easing, and is likely to increase in PHP, and that's overall a good thing f= or the language. It fits well with a number of recent RFCs both passed and= proposed, and makes writing functional-style code much more natural. > > I like it. > > I hope this passes, and would vote for it if I had a vote. > > -Mike > > P.S. I do find myself lamenting that while this FRC makes code more conci= se it does not do anything to reduce the (IMO overly) verbose nature of met= hod declarations that require both a visibility modifier and the function k= eyword. And while I know you just stated that conciseness in not a main goa= l, it is still a benefit of this proposal. > > It would be much nicer if we could indicate in fewer characters what the = visibility modifier and the function keyword currently denote. Yes, that co= uld be addressed in another RFC, but it could also be addressed in this one= =E2=80=94 assuming there was a will do to so =E2=80=94 so now felt like a = good a time as any to bring it up. > > Assuming others besides just me would like to see function signatures be = made less verbose and would like to see some proposed alternatives, please = ask and I will happily follow up with some ideas. Drop "public", as it is unnecessary. I never understood why PSR-whatever decided to always require it, when not all projects agreed on that, and there are actual arguments to put it only when overriding visibility (you see it only when it matters). Anyway, it's not that important, as I don't have to do what PSR-whatever decided. Instead of writing this: ``` class A { public function method($arg1) { return expr($arg1); } } ``` I can write this: ``` class A { function method($arg1) { return expr($arg1); } } ``` To be quite honest, I like putting statements on a single line as long as they fit in whatever column limit the project uses. My .clang-format has been doing this for my C code and I've grown quite fond of it; there is real value in seeing more actual code on a page at a time, and I don't feel like it's too cramped.