Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76222 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44763 invoked from network); 28 Jul 2014 09:07:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jul 2014 09:07:12 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.52 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.52 mail-qa0-f52.google.com Received: from [209.85.216.52] ([209.85.216.52:51308] helo=mail-qa0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F2/74-26001-FB216D35 for ; Mon, 28 Jul 2014 05:07:11 -0400 Received: by mail-qa0-f52.google.com with SMTP id j15so7311515qaq.25 for ; Mon, 28 Jul 2014 02:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=njAEy60z8NZxcNKH8Q+L3ccyevpve5faOSv9xnrRRRY=; b=uVgBSLaEinjHa+UCxxoIb6rKIOZUqrD72IRRWe3YMa9QUhjXdEKX3PIPYiMRdI3k38 VgBmyqJCD7Oz2zufgl6atepxO2aRm9KdiNRhSXhSR3bkAWHfQiXJWG6ESWJg0JE1F5zc 39tQrRBL9iPBnqV6uiaPe7Du5OE2bB89Alo7ls/vUajwZkoajDWCwfL+nrERpHpuo8L/ 9d7tVM6E2hiVy7dx4tBIwkuB1e9Sp4b2k0rWJPmi4K2BT3ID7c0xoMD7Rt7KGvpQux6F eRDylArE0OKIIWXYtp3ij3jikVlvE/havp05oZxmiijsutltbnUCBFpRB6jI6CviZveb iKhg== MIME-Version: 1.0 X-Received: by 10.140.80.165 with SMTP id c34mr3037387qgd.79.1406538441108; Mon, 28 Jul 2014 02:07:21 -0700 (PDT) Received: by 10.140.102.111 with HTTP; Mon, 28 Jul 2014 02:07:21 -0700 (PDT) In-Reply-To: References: Date: Mon, 28 Jul 2014 11:07:21 +0200 Message-ID: To: Peter Cowburn Cc: Yasuo Ohgaki , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c1311c253b3b04ff3d403c Subject: Re: [PHP-DEV] "PHP" namespace? From: tyra3l@gmail.com (Ferenc Kovacs) --001a11c1311c253b3b04ff3d403c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, Jul 28, 2014 at 10:49 AM, Peter Cowburn wrote: > > > > On 28 July 2014 09:22, Ferenc Kovacs wrote: > >> On Mon, Jul 28, 2014 at 4:58 AM, Yasuo Ohgaki wrote= : >> >> > Hi all, >> > >> > Since we have discussion for Next PHP, "PHP" namespace discussion woul= d >> be >> > nice >> > to have. >> > >> > Currently, PHP module functions/classes/interfaces are using >> global(root) >> > namespace. >> > If it is changed to use its own namespace, user space APIs may be >> changed >> > flexible and user controlled manner. Thus, PHP may have >> > >> > - Consistent naming >> > - Consistent parameter order >> > - Graceful function/class/interface deprecation >> > (We know what we should do for these, right?) >> > >> > without much compatibility issues. >> > >> > >> > "PHP" namespace may be used to provide PHP(and 3rd party) >> > functions/classes/interfaces/constants. >> > "PHP\Legacy" (or whatever) may be used for legacy >> > functions/classes/interfaces/constants. >> > >> > From PHP 5.6, userland function aliasing can be done with namespace. >> > Following code overrides existing function. >> > >> > > > use function \mb_strlen as strlen; >> > var_dump(strlen('=E6=97=A5=E6=9C=AC=E8=AA=9E')); >> > ?> >> > >> > Result: >> > int(3) >> > >> > It's good to use prefered API, but it requires "use" for every functio= n >> > APIs to be overridden. >> > Note: Classes/Interfaces may override by "use" one by one also. >> > >> > With "PHP" and "PHP\Legacy" namespace, user may write: >> > >> > > > namespace PHP; // Use current PHP functions/classes/interfaces/constan= ts >> > >> > // Code uses current API >> > ?> >> > >> > > > namespace PHP; >> > namespace PHP\Legacy; // Override with legacy PHP >> > functions/classes/interfaces/constants. >> > >> > // Code uses legacy API >> > ?> >> > >> > For compatibility, default namespace setting would be nice to have. >> > - None for compiled default >> > - "PHP" for php.ini-* >> > >> > Previous example codes became: >> > >> > > > // Code uses current API >> > ?> >> > >> > > > namespace PHP\Legacy; // Override with legacy PHP >> > functions/classes/interfaces/constants. >> > // Code uses legacy API >> > ?> >> > >> > Issue would be codes that assume PHP >> functions/classes/interfaces/constants >> > are >> > defined in global(root) namespace. (e.g. \strlen()) This could be >> > workaround by allowing >> > "use" aliasing to global(root) namespace. (e.g. "use PHP\Legacy as >> \;") In >> > this case, >> > current functions/classes/interfaces may stay in global(root) namespac= e. >> > (or "use PHP as \;") >> > >> > >> > Programmers may shoot their own foot by this. This is the trade off of >> > flexibility. >> > >> > Any thoughts and/or comments? >> > >> > Regards, >> > >> > -- >> > Yasuo Ohgaki >> > yohgaki@ohgaki.net >> > >> >> hi, >> >> I think it would make sense to announce that the php namespace is reserv= ed >> for internal use, but I don't think that we are ready for moving >> everything >> under namespaces. >> > > For what it's worth, the manual already states that the "php" namespace i= s > reserved for us.[1] > > hehe, was trying to check that before sending the mail, but couldn't find it, thanks! --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --001a11c1311c253b3b04ff3d403c--