Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108514 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 73649 invoked from network); 12 Feb 2020 20:26:46 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Feb 2020 20:26:46 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BC4C4180551 for ; Wed, 12 Feb 2020 10:40:57 -0800 (PST) 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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,SUBJ_ALL_CAPS 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-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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, 12 Feb 2020 10:40:57 -0800 (PST) Received: by mail-lj1-f182.google.com with SMTP id o15so3520852ljg.6 for ; Wed, 12 Feb 2020 10:40:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RxBGyU3Uu3siHA7THp8VLY5j7L9PVkWvDr9pK2VGJL8=; b=J0agWfBuvKx00+GDA3BsZTRQ5itNtczUhSTusvtRBm8+hi59pDT+Viq7xCLcDpR2EY phw5hBNYKgUfHsMOmFSpDmCg2AiB1UHxmMFRxWbLfGhi1aDESsi1M40nvRxCJoNb7pln TvaY9Lq7fObHdJ+XCvNixAkjW4y5pNjc6H7n569y1QbDNANfy7U0CrP6rwMpKnvmxWTX 3zfnwJemUR2gELEgKidq/5MDYFrr3lUgK0/5GPj82d2UM8xQYxBSUu4sT7ArYVhjl9mn 70NRJwJg5Z26eq+nI+uYk/6Q3rOoALs5HvI+e6SpUHpgrBOtTrQCEPSRKSc7ZOIe6sJI 2xrA== 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:to:cc; bh=RxBGyU3Uu3siHA7THp8VLY5j7L9PVkWvDr9pK2VGJL8=; b=Zv8NFxjgLKmqZY4UYI+V0n0IHpFwpFAAdX+pX1sMCN1QupsF/8vHkfSXpUcoaaL0oT p8rQBE8LK/YmqzDfT2RwSkArccB8heRZMYUkD5C3m6VGUC7s1da/+Kee9Uzr4x+Yyads AMqKgKWZ+SLvpTs16olw5DYtYXZtnCIO3Ms1sYVcRw0BqC3V8z504JQLhhfZ8AtATzI0 KWtBj4n5dPP+LhYIslqIArr2hJ58wpXxMAULROmfMVlLX/hIH6+TcSo+NBAyOC262X+B C9ZxCWG28iFkfQmFHjNsHY/uZxBfMcpe/FIdbOQITKpC6og6fxf/Jv/B+E8rTKBnuyyq XSSw== X-Gm-Message-State: APjAAAUDMrMz9nO67ebwSwX4yaDy/LhZJhMYpqJWrqk1QaSn7X35iwjK Ii1446VHUwyNZma1y4qINhsYolshwsT2l6yP/9Q= X-Google-Smtp-Source: APXvYqySzUgW8iLfq4kR+S8RSqvJm+ywVjRzJ5VxiYxhKX237F+iiNgxbQBvxIGxKEJu3VLI6Dk/KXHoYzd6+PySTNI= X-Received: by 2002:a2e:a490:: with SMTP id h16mr1233993lji.115.1581532852629; Wed, 12 Feb 2020 10:40:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 12 Feb 2020 19:40:40 +0100 Message-ID: To: Dan Ackroyd Cc: Nikita Popov , Nicolas Grekas , Diogo Galvao , PHP Internals List Content-Type: multipart/alternative; boundary="000000000000e1b426059e654f46" Subject: Re: [PHP-DEV] [RFC] From: manuelcanga@gmail.com (Manuel Canga) --000000000000e1b426059e654f46 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 12 Feb 2020 at 15:08, Dan Ackroyd wrote: > On Tue, 11 Feb 2020 at 13:19, Nikita Popov wrote: > > > > https://wiki.php.net/rfc/consistent_callables. > > > > btw it's probably worth mentioning the other reason I didn't pursue > https://wiki.php.net/rfc/consistent_callables. > > By itself, the callable type isn't much use. It only allows you to > specify that a type can be called, but it doesn't allow you to specify > what parameters the callable should take, or what the return type > should be. > > Just making the callable type be consistent would be a lot of work, > and possibly cause a lot of BC breaks and still not do the useful > thing. > > Instead what would be far more useful would be allow people to define > the callable signature, and use that as a type. > > callable some_callback(int $x, string $y) : int; > > function bar(some_callback $fn) { } > > $fn_correct =3D function (int $x, string $y) : int {} > $fn_wrong =3D function (int $x, string $y) : int {} > > Calling bar with $fn_correct should work. > Calling bar with $fn_wrong should give a type error. > > In my opinion, pursuing that idea would be a lot more valuable than > breaking BC for callables without much gain. > > cheers > Dan > Ack > Hi, internals, I think, we are taking this very far. In Spain, we usually say: "Quien mucho abarca, poco aprieta". In English, I think is similar to: "don=E2=80= =99t bite off more than you can chew" or KISS/YAGNI in development. IMO, we should limit RFC to '::function'( scope and accept/reject ). After this, other RFC can be added/checked like Short closures( of Michal ) or other purposes with other variation like :interface and ::trait: ( of Mike ) Respect to ::function: ::function, it should return a string like ::class. This is= : Case 1: ::function =3D=3D=3D \namespace\function_name ( when function_name is imported ) Case 2: ::function =3D=3D=3D \current_namespace\function_nam= e( when ::function is below a namespace ) Case 3: ::function =3D=3D=3D \function_name( when ::function is not below a namespace ) Case 4: \namespace\::function =3D=3D=3D \namespace\function_= name Case 5: \::function =3D=3D=3D \function_name ( equal of 4 bu= t in global context ) Examples: 1. namespace my_project; use function \vendor\I18n\translate; $mapped_array =3D array_map(translate::function, $array); //=3D $mapped_array =3D array_map('\vendor\I18n\translate', $array); 2. namespace my_project; $mapped_array =3D array_map(translate::function, $array); //=3D $mapped_array =3D array_map('\my_project\translate' $array); 3. $mapped_array =3D array_map(translate::function, $array); //=3D $mapped_array =3D array_map('\translate' $array); 4. $mapped_array =3D array_map(\vendor\I18n\translate::function, $array); //=3D $mapped_array =3D array_map('\vendor\I18n\translate' $array); 5. $mapped_array =3D array_map(\translate::function, $array); //=3D $mapped_array =3D array_map('\translate' $array); Although, cases 3, 4 or 5, can appear useless, however editors could distinguish when is a function( and not a ordinary string ) and validate if function exists or not. Regards --000000000000e1b426059e654f46--