Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108536 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 17393 invoked from network); 13 Feb 2020 13:50:20 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Feb 2020 13:50:20 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3A5051804AC for ; Thu, 13 Feb 2020 04:04:43 -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-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 ; Thu, 13 Feb 2020 04:04:42 -0800 (PST) Received: by mail-lf1-f41.google.com with SMTP id t23so4084831lfk.6 for ; Thu, 13 Feb 2020 04:04:42 -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=cTS4lCL3ix70UEWK+uTReGshabzRUyxgEZZLh90xtq4=; b=bvq7ilB9ydYSKhTQ+oF7T3ntiK5t6PnqA4dmtvk6UhiI5wtiDjf1fgWVl1IR4s3CDu IGqR3gumcVbgo+j4rvJLMsCWInTxnC7mhvJPunzxk69KDUWZFH2OgFvXJ8fIBUfKXyaO ichyLkrJOCkR8eax5RAZcdyWhlbhCjrpyEHLGjRKx+j68zzVNzP+rkSSIQWDiG8a6P8i HadaaBgpgBw5a13+XTSJ068UwjddwnOuV4G6kytRIbnuY6if9vYUdhfDrvPyr+p7qGTZ 992NjdTBqI4L2Wk3RdH1IIhufEprE6kdi5IX9/yEAEgtTPDliXX+78G7FwH88hhcrvs6 BLjw== 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=cTS4lCL3ix70UEWK+uTReGshabzRUyxgEZZLh90xtq4=; b=tPPapSWWO4uLJRI1F+8q0W5h5IAdWKb4Ucb2yhHqxQ+8lJUO2mM+En5oss8f9KFAEL I89YnvyNkNHw5yLOuXADy1nnVdOxXUvuYMXEOL0DZ8agrx+MJZA4DSg+PwNV3Ci4Xeq3 5PX8tAMYhAxH1dh66XC5pMT5P32tcLMn44FAjlBuo6hw+5/wzEu9ZmTAoKn7EbW04mPk ZGjqpwE0VhMhvGd0EhdQZCvKENL05sHGlEUKPI0TGlqmRscPWCP2TJ6SF4Baw2yShXfX I3QR2YxXy+9tu2F9iV+uCupt1SlxobPizvmk5G83PwXpIv5r2Wysl+tZaQ5u8MRIw3yz WhBA== X-Gm-Message-State: APjAAAXIbuINM90UvOMFvfHuI5EOwNprnkON1l9oX/TZT5m/Gc2ok8l1 hkDnBHt3kfZ36xJEszTbU8qxRr6lsEycUGAzYBI= X-Google-Smtp-Source: APXvYqy2ZifanHzmalB6k+rxpkOmboBTRrRcZlzW1K2hk5dS3wp0Nt0e2do0Dyq9a6pg9W8d//MuM2vFaop2fWnQxVc= X-Received: by 2002:ac2:5596:: with SMTP id v22mr9302613lfg.200.1581595478810; Thu, 13 Feb 2020 04:04:38 -0800 (PST) MIME-Version: 1.0 References: <9829e5c9-9e32-9686-8ff2-ec7930dda709@gmail.com> <20d9da97-243a-a171-0412-7298b79e4dde@gmail.com> In-Reply-To: Date: Thu, 13 Feb 2020 13:04:26 +0100 Message-ID: To: Rowan Tommins Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000b16598059e73e489" Subject: Re: [PHP-DEV] [RFC] From: manuelcanga@gmail.com (Manuel Canga) --000000000000b16598059e73e489 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 13 Feb 2020 at 08:58, Rowan Tommins wrote= : > On 12 February 2020 23:12:34 GMT+00:00, Manuel Canga < > manuelcanga@gmail.com> wrote: > >El mi=C3=A9., 12 feb. 2020 23:01, Rowan Tommins > >escribi=C3=B3: > >In your example, you has the same options: > > > >> > >1. Change import > >2. Add namespace: > > > >['Acme\Global\I18N',\translate::function] > > > There is no collision between 'Foo::translate()' and 'translate()', so > there is no reason to change the import. That's true of executing the > functions, so it should remain be true of resolving them to strings. > > There is collision with import which you added. > > > >Explain: > > > >When you do: [ class, method ] or [ $object, method ]. Method has not > >namespace, you write it without namespace( like global functions ) > > > I think this is where we are thinking differently. A method name is not > "like a global function", it's just a name; it doesn't belong in the same > category. > > You might have any number of classes that use the same method name, but > with completely different parameters and purpose, so "a method named foo" > isn't a useful concept outside some specific class or interface. > > On the other hand, you can only have one function with a particular > fully-qualified name, and the proposed feature is a way of referencing th= at. > > Function as callable is different as regular function. Example: http://sandbox.onlinephpfunctions.com/code/99408213d1ed740f60471646f16f9765= d7efa93e namespace MyProject; function my_function() { //.... } my_function(); // it calls to \MyProject\my_function array_map('my_function', [] ); //* * Here, 'my_function' is only a string. Maybe a global function( without namespace ) or maybe a method or other case. With native array_map is a global function. However, you can have a function like this: function array_map( $method, $array) { \Collection::$method( $array ); } In both cases, you could do: array_map(\my_function::function, [] ); > > > >Other example: > > > >$class =3D \MyClass::class; > >$method =3D \method::function; > > > >and... > > > >$class =3D '\MyClass'; > >$method =3D 'method'; > > > >$obj =3D new $class(); > >$obj->$method(); > > > >Both are the same, but first is more semantic. > > > This isn't semantic at all - it works only because \method::function > happens to return the string you want, but so does \method::class; neithe= r > is actually labelling it as what it is, which is a method within class > \MyClass. > > Importantly, it might not work at all, if ::function gives an error if > the function doesn't exist. > > ::function only would retrieve string, like as ::class, exists or not. In fach, that code might not work at all due to class. What matter if Class does't exist ?. ::class doesn't produce error. Look: http://sandbox.onlinephpfunctions.com/code/0a8466a00974bc1ffc12b219569ced55= 753327bd If class doesn't exist, nothing happend. Thank, Rowan. You points of view are very interesting. --000000000000b16598059e73e489--