Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118422 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 85147 invoked from network); 11 Aug 2022 17:05:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Aug 2022 17:05:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 79095180549 for ; Thu, 11 Aug 2022 12:07:24 -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,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 11 Aug 2022 12:07:23 -0700 (PDT) Received: by mail-ej1-f51.google.com with SMTP id j8so35092747ejx.9 for ; Thu, 11 Aug 2022 12:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc; bh=ynWiFO833m/8JeGf0dm0zS7C3O038EOik15Fcvvr0o8=; b=LP3CL+oIVCMHn+KukuaRl2xMbCVzKSH1KPTPMVMjZSwKsw95vLcRGMuVLIGxBv9m6g 1foasSGb7iatfBzyQAiLoVQ7m9EPtMOMQeSdUrL4W9SuWReP410th26CyVRn9MNiA3tA RDV/grxSElO3wC3x3pU++7reOR2gJRmD/u854Cra0dq77SegLKdE9jS7Pe2BRtbsegsq MteLEpRYDxzCmso05LlX2L/5QIQPPYJcQ+5L+WGJ7pEPhKtr2SHeajvr/ostMFSZQlX9 akb1K5jCdS99U/dQEZeS25lye2QA33EYYGpw3hgLbRaCbC4fUYHYBJXOv+x+ie9j6VSP oOJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc; bh=ynWiFO833m/8JeGf0dm0zS7C3O038EOik15Fcvvr0o8=; b=VQtpCnj41A5Spn4MMeLHjysh2lnADsA+qJ67XPSO+D4Io/oXutj692Bheq11EcjlrT NUDsArSC9487aStLM8nxt2n/UaMXSS5LvVwazBDAqesxa1CsnFKWjDgq38DHDWyIM1vp cDZIwgMTb4egYJMswsaktLElESCNa+w9t5gQ5BH1zLFG+1xgOwxGPPpyxLSWwiSYqKL5 zpAcg9WRmXSb9B8wRVa3O9UfvGSYegpIQVh6O/PTXpX+E4LJe2vz4dR//sLhpPsPluL3 BEyZwsk0qI9vP5VNYiv9G5nDis+QiPAhgeOMxR3EOR9stHUC73QcF6gMcYKoApWw3lEX Sd5Q== X-Gm-Message-State: ACgBeo2+nEPgoq7/eWKmxVxxVIPUi3z/GMlFXXJnngiHn2vEW1mjK/dt wfVnpbDwklnh/aTOy0mY780= X-Google-Smtp-Source: AA6agR4qDPZLZROMevf0Sl683g+auNMVgVgbGgfIGDgDAftjlIexCTnZCinnoEE2tmVbAprObVllNA== X-Received: by 2002:a17:907:a068:b0:731:366a:6005 with SMTP id ia8-20020a170907a06800b00731366a6005mr347263ejc.344.1660244842759; Thu, 11 Aug 2022 12:07:22 -0700 (PDT) Received: from smtpclient.apple ([93.175.202.231]) by smtp.gmail.com with ESMTPSA id kk18-20020a170907767200b00704fa2748ffsm3813220ejc.99.2022.08.11.12.07.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Aug 2022 12:07:22 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) In-Reply-To: <06d0c009-2ea5-47cb-beb2-eb6f033d41c3@www.fastmail.com> Date: Thu, 11 Aug 2022 22:07:20 +0300 Cc: php internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <62f48769.250a0220.37387.53b5SMTPIN_ADDED_MISSING@mx.google.com> <01D4987C-FD37-4BD2-A1AC-DD10F808F248@gmail.com> <69767A9B-B336-49AC-8932-C895DB3B373D@cschneid.com> <6717F20F-D27A-4BF7-8C59-71126B1D1F50@gmail.com> <06d0c009-2ea5-47cb-beb2-eb6f033d41c3@www.fastmail.com> To: Larry Garfield X-Mailer: Apple Mail (2.3696.100.31) Subject: Re: [PHP-DEV] [Concept] Extension methods From: autaut03@gmail.com (Alex Wells) > On 11 Aug 2022, at 21:58, Larry Garfield = wrote: >=20 > On Thu, Aug 11, 2022, at 1:51 PM, Alex Wells wrote: >=20 >> The pipe operator RFC has actually been mentioned before; the short=20= >> takeway is: pipe operator works and has a benefit of using existing=20= >> functions. The downside is that those are still functions, not = methods,=20 >> meaning you=E2=80=99ll still be left with `[your_type]_` prefixes for = all=20 >> function names, unlike extension methods, where you can have multiple=20= >> methods with the same name (for different types). >=20 > This is incorrect, and has been since functions could be namespaced. = Please stop repeating this, it is FUD. >=20 > Also, "existing functions" is also not quite accurate. PIpe worked = with any callable; the Partial Function Application RFC was intended to = make turning arbitrary functions into callables, which could then be = easily piped, but you can also use arbitrary callables, including = closures and objects that implement __invoke(). array_map in its = current form wouldn't be pipeable anyway as it requires multiple = arguments, but higher order functions that are pipe-friendly as trivial = to write. (See previous message for a link to many.) >=20 > --Larry Garfield >=20 > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php >=20 Functions can be namespaced indeed. I=E2=80=99m referring to another = thread where I brought an example with `Collection::map` and = `array::map`. You can easily define those as functions in different = namespaces, but when it comes time to use it, you=E2=80=99ll likely end = up having to use the same function name in a single file. It=E2=80=99s = then one of three options: 1) you don=E2=80=99t import your functions, leading to ugly long calls: = `\Illuminate\Collection\map(=E2=80=A6, fn () ..)`, = `\Some\Vendor\Arrays\map(=E2=80=A6, fn () ..)` 2) you do import your functions, but end up aliasing: `use function = Illuminate\Collection\map as collection_map;`, `use function = Some\Vendor\Arrays\map as array_map;` 3) you define your functions with prefixes from the beginning, just to = avoid having to manually alias them all the time: `use function = Illuminate\Collection\collection_map;` All of the solutions are far from perfect. I apologize if I=E2=80=99m = missing something.=