Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114971 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 99730 invoked from network); 19 Jun 2021 08:04:48 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Jun 2021 08:04:48 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 612CA1804C8 for ; Sat, 19 Jun 2021 01:22:15 -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.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) (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 ; Sat, 19 Jun 2021 01:22:14 -0700 (PDT) Received: by mail-qv1-f49.google.com with SMTP id c10so4821332qvo.9 for ; Sat, 19 Jun 2021 01:22:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=o9oREe3X4LwbfQSRvk6mRPeHk+CbOh4XPRKhIQInLoI=; b=cyWz0GnnjHH9zAOqOSL9rZM2ibuRiE/U5FeRTvT7nMiVylT5ls5RIzrukBvQ/U/eUL hvHvQvI5mVvzBE8iddgM4Ix5l6atSJX6n6ZQw5EE4qL6TILaz/SNrLo4R++i/+mf/NKA MOvlbljzvNIc9+tZs3beheKNkcEeq7fxhdiYN+LlfNoMF2d34+vpjPXRWR156iTTVNJo tAyrT39a1yedYwDoBi32v5zMPD5Mr1VCbkW7BY2q25AO7e6vFsAvVx89ymfE4kgsepiL z/WYL62dQAWvhV5N0q28bYq5nZKYq6PA20WSG+UNjyRM9VrlTexN4nuO+ahW403eQOQd XMAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=o9oREe3X4LwbfQSRvk6mRPeHk+CbOh4XPRKhIQInLoI=; b=Fdq0+rBRXlkSmKDrHEQZa+zcQ+xqQZWYKlXl2H5v/kUNuwHdc+V1GZvY0/2bsX9w3H XpveKFVFyUD88o3xOuUifKxrT5as5U6oM/9qFADYDSQGrXjlNosvJzzlvRjVOBIuGIG/ FCe80TNrsvkP2PPeaN2tyUhztwI2rqHxh5Fyn/znoxFZmXZJ6SfIDqEGbUykxKn9DNYr X6tXJM79C8l1pes7CXewm2HzIVMtEhWPLFmXiS90ZA5KRTX0c5Z69VCDbpu/SVZes55Z XM9CTuZQ+SCwnLNKjYiijLn/kIgAzEJcbRLuiGLPdXOICtFNkcvFv6vtDlgj/u64+VbL eLZQ== X-Gm-Message-State: AOAM531lEoxtLTFf6mQiUIbGAkzy3hlR9sXp5941n7EqsUQnLep1Ou+I It/H/J6Kq4jkgImoc24J1yWyIw== X-Google-Smtp-Source: ABdhPJw0XACQAJWGcTnOrPUiH5aqZK6m5Y4n+NrXjVuQoQzpUgyovBs9V1l6BVkFc3LG+U2HkzE6wA== X-Received: by 2002:a05:6214:8f1:: with SMTP id dr17mr9568202qvb.42.1624090931637; Sat, 19 Jun 2021 01:22:11 -0700 (PDT) Received: from [192.168.1.10] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id e20sm6658460qtr.55.2021.06.19.01.22.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Jun 2021 01:22:11 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) In-Reply-To: Date: Sat, 19 Jun 2021 04:22:08 -0400 Cc: php internals Content-Transfer-Encoding: quoted-printable Message-ID: <37A59CDF-D3C7-4B3D-B389-CF2D9052C8FF@newclarity.net> References: <222b3921-3d9b-47f9-8d13-e6a123f36fad@www.fastmail.com> To: Benjamin Eberlei X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] [Vote] Partial Function Application From: mike@newclarity.net (Mike Schinkel) > On Jun 18, 2021, at 7:41 PM, Benjamin Eberlei = wrote: >=20 > On Wed, Jun 16, 2021 at 6:17 PM Larry Garfield = > wrote: >=20 >> Hi folks. The vote for the Partial Function Application RFC is now = open, >> and will run until 30 June. >>=20 >> https://wiki.php.net/rfc/partial_function_application >=20 > I wanted to explain my no vote on this one. >=20 > The examples section shows how every use-case of partials can be done = using > short functions and while this is often a lot more to type (especially = if > you mirror the typehints), these extra symbols feel necessary from my = POV > to make the code clear that creates a partial. >=20 > Especially the ... as "additional" arguments and its various = interactions > with ? produce so many different ways of calling something, it feels > unnecessary to me to introduce this complexity to newbies that might = come > across use of this functionality. Plus the additional edge cases of = delayed > execution, non-support for named parameters. Its a lot to know to = fully > understand this feature. >=20 > Given that the functional paradigm isn't widely spread in use across = PHP > developers, i am not convinced that we should add more features in = this > direction that increase the complexity of understanding the language = by > that much. While one could argue that functional paradigm isn't > wide-spread, because these features are missing, it is my believe that = the > majority of PHP developers would still rather prefer imperative = coding. >=20 > As a thought experiment I tried to think of code in our codebase that = we > could convert to PFA once we migrated to 8.1 and there just isn't that > much. This is very different to short functions, nullabilty operator = and > other "glue" / sugar proposals that were added to the language lately, > which a lot of existing code benefits from and existing code could be > converted automatically to them using phpcs/phpcbf rules. >=20 > I also am wary of the future after this RFC, as it states it is the > launching pad to another attempt at the Pipe Operator, which also = proposes > to do a thing (calling functions) in a completly new way that will be = hard > for beginners.=20 Just to offer a counter perspective since the assertion was made that = partial functions would be hard for beginners. I believe beginners will have a harder time comprehending closures, and = especially short closures, than partial functions. And especially for = the use-cases which are likely to be more common, none of which are any = more "functional" in nature than PHP already is. The use-cases I think = will be more common? Calling any of the existing built-in PHP functions = that accept a callable as a parameter. I am no expert on beginners but I did teach beginning programmers in a = classroom setting for a decade. One of the biggest stumbling blocks I = have found for beginners is excessive syntax that looks complex. Many of = the concepts themselves are less difficult for beginners to understand. =20= So, in my experience it will be easier for newbies to understand this, = for example: array_map( $this->sanitize_value(?), $values ); Rather that this: array_map( fn($value) =3D> $this->sanitize_value($value), = $values ); The latter just has more sigils to grok than the former, and from what = I've seen with newbies when you throw too many sigils at them they = quickly move into a learned helpless state and think that it will be too = complicated for them to understand. Bottom line though, what I am saying about newbies is just my opinion = and probably biased by my own personal sensibilities.=20 If we want to consider how beginners will grok new features we should = probably find a way to solicit objective feedback from beginners to = consider in RFCs. Otherwise I fear each of us may just be assuming that = beginners have the same sensibilities as we do.=20 ----- And where most of us would be still using strings for function = callables, the benefit of PFA for non-beginners is they let us use = symbols to aid refactoring, static analysis, IDE functionality, etc.: array_map( intval(?), $values ); Rather than: array_map( 'intval', $values ); Of course we could use this, but seriously how many of us are using the = following structure rather than just passing the function name as a = string? array_map( fn($value) =3D> intval($value), $values ); > I also am wary of the future after this RFC, as it states it is the > launching pad to another attempt at the Pipe Operator, which also = proposes > to do a thing (calling functions) in a completly new way that will be = hard > for beginners. I hope we don't add both these features to keep the = language > smaller in this aspect of how functions are called. For the record, my gut tells me beginners will not grok the proposed = pipe operator as easily as I think they will partial functions. But who = actually knows for sure how newbies will comprehend pipes? -Mike >=20