Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108463 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 97710 invoked from network); 11 Feb 2020 13:33:24 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Feb 2020 13:33:24 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 15BD0180210 for ; Tue, 11 Feb 2020 03:47:19 -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, 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 ; Tue, 11 Feb 2020 03:47:18 -0800 (PST) Received: by mail-lj1-f182.google.com with SMTP id x14so11175398ljd.13 for ; Tue, 11 Feb 2020 03:47:18 -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=gaR41JKKwWU1qlpk0OhttLaeZGRbyUQ3KA+TtFTn5I4=; b=UaJjgHcKMJkCMP5BCy8Ij7Bq/E0/0CI2P0k8EsjOze+3+8PZ6Hngi948+2JVz4Uk6M OpvmDMgt63PU6oy+gQy7paKFVS7tWargFMEebO139FQl/JRAzbmZzEz7HmP+oYHn+Zp0 NG69SdB2O6Uu6McyC2vytvejq1pu644obG8/i2dkOkokpyWRpSfvMrKUl/Ogm8yq1UAx T0RNO7BJBoSbT8WWYtBkQ5y7RWy/71rtzAx+AylNVYKqNJNsoHtR2/utK4WCrRdaKxI7 P75AbA8U96mZP40vOvVIWyQpeDcRauZULL9cafnFN0GpOOPFQXoEu6GtYb4b7+gEg4Nl U6jQ== 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=gaR41JKKwWU1qlpk0OhttLaeZGRbyUQ3KA+TtFTn5I4=; b=N7KppfdfAVx8y8Zex7CLfOZV89++DiVYEAcVUMjdfJCfoZamdMgwlY9GkEaI7jKG8R akmFXnDuoJyvtbe1a8QewlUOUZBHFzcO6evv3jKwsmQrcUOXbBbsirv16gRB3AxcMSOG hqcXpDLSpHAI8qKa38rh3CnXuGrMSjSKofujGxceUTTgHZtFNJ4Pfk2RswnDFyhDz2Ar AcGk2OH8jG/tPaLuW37uk4oTcQW8bUTIf22KQUqtsEgsy9F7njuoic2xdsTV8rjFIEGs EBXECSbLD9UrJtwhsOnhT+FOdV6dEPF545Q9u+HEtwLQGzomlJLSNPwoTvob5XDYOYWD DOkw== X-Gm-Message-State: APjAAAWe6pIciGJKAO0Pmo8jDNiaWLzrrwNyae96I1U5B/Dd46O08g0u 1oOMbv3Jt2O2Y4LTy/ViGlvU+QjXOWuq2ZvImr4= X-Google-Smtp-Source: APXvYqw2Og5U3RAZC0a+BBPW1vu5uKTMGkHQjOimmZDEoNAeBHikrplroPheZkfwdoA3B1PJQifU3L97FzM3v2PDTyI= X-Received: by 2002:a2e:b4cf:: with SMTP id r15mr4012831ljm.52.1581421637096; Tue, 11 Feb 2020 03:47:17 -0800 (PST) MIME-Version: 1.0 References: <1581420814.35391.0@inventis.be> In-Reply-To: <1581420814.35391.0@inventis.be> Date: Tue, 11 Feb 2020 12:47:05 +0100 Message-ID: To: Tom Gerrits Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] From: manuelcanga@gmail.com (Manuel Canga) Hi Tom, I thought about that short version. However, in order to avoid conflicts with constants, I chosen "::func". If this is not problem in low level of PHP, then I agree with you in shorter version is better. Thanks for your opinion, Tom On Tue, 11 Feb 2020 at 12:33, Tom Gerrits wrote: > > Hi Manuel > > Thanks for bringing this idea forward. > > Adding a non-string construct to reference functions uniquely seems > like a good idea and would be consistent with the existing ::class > keyword for classes. > > I'm wondering if it would be useful to take a page out of the book of > other programming languages in order to shorten the notation further: > > > // First file. > > namespace A\B; > > > > function foo() { } > > > > // Second file. > > use function A\B\foo; > > > > function bar(callable $c) { } > > > > > > // Current approach. > > bar('\A\B\foo'); > > > > // Notation without parantheses, references imported function. > > // Similarly, in the future, Class::method could reference a > > // class method. > > bar(foo); > > > > // Notation with references, could be expanded in the future > > // for static class methods, such as &Class::method. > > bar(&foo); > > The second example can already be achieved by defining your own > constant that references the fully qualified name and importing it. > However, an explicit, separate, import of these constants is still > needed, which is not ideal. > > A suffix "::func" would also be useful, but allowing shorter notation > would improve readability when using the functional programming > paradigm and composing functions. > > Op di, feb 11, 2020 at 12:13 schreef Manuel Canga > : > > Hi internals, > > I Would like to present a possible new "::func resolution" for your > > consideration. > > > > In first place, PHP now support "::class" in this way: > > > > use My\I18N; > > > > $mapped_array = array_map([I18N::class, 'translate'], $array); > > It avoid add Full I18N namespace in callback. > > > > However with functions is different: > > > > use function \My\I18N\i18n_translate; > > > > $mapped_array = array_map('\My\I18N\i18n_translate', $array); > > > > What is the useful here of importing the function?. > > My proposal is ":func" in order to avoid full namespace in callback of > > functions. E.g: > > > > use function \My\I18N\i18n_translate; > > > > $mapped_array = array_map(i18n_translate::func, $array); > > > > "::func" should validate if a function with `` is > > imported. > > In this case, "::func" is replaced with FQN of this function, > > otherwise with only "" > > > > What is your opinion ? Do you see it useful ? > > > > Thanks and I'm sorry for my English( I'm a Spanish ). > > > > Regards > >