Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76212 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91878 invoked from network); 28 Jul 2014 02:59:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jul 2014 02:59:22 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.53 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.215.53 mail-la0-f53.google.com Received: from [209.85.215.53] ([209.85.215.53:50964] helo=mail-la0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A8/00-26001-88CB5D35 for ; Sun, 27 Jul 2014 22:59:21 -0400 Received: by mail-la0-f53.google.com with SMTP id gl10so4867055lab.40 for ; Sun, 27 Jul 2014 19:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=+9JJ8QAeFQnCUWGy5ofWRU6ieinBOg1sdwcvWJ/BeDg=; b=EtqGXXuT8ylthiUU2zNttimu+vzz4qNdOwC9wLbzHKeU6gyq0jlSLm9SH3vfHdUGZp smUVKmtzJnLqYHNp4Ht7Yw3cSZ/rPyINTKa0rMlPyYqJOWlPDtQfEutmgfrdvHbrS2rd /qGy3zum8Dn/90QAORGowRJ9lSD8D4AkzcT3DnwGy86RO3EeqQFHrkWTyDDVFTseC+Zm 2JjuzDsPfVeQJ97/VlOik3bEl6uEBEVUr3U297hX4X6PTwabIaxiCB9LLAGODNPZTsNh 3sVf+0qTB9mpexdbcXMENbyiDvMMBDgIgkTwPou2zZgIAKDOq2SgddtWa7NEIa1HAdXe +b5Q== X-Received: by 10.112.97.163 with SMTP id eb3mr17207192lbb.67.1406516368929; Sun, 27 Jul 2014 19:59:28 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.214.228 with HTTP; Sun, 27 Jul 2014 19:58:48 -0700 (PDT) Date: Mon, 28 Jul 2014 11:58:48 +0900 X-Google-Sender-Auth: ll99BDq8wOGhqYBzSBZxVd1RE9Y Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1133c20a8a7ad204ff381c6b Subject: "PHP" namespace? From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a1133c20a8a7ad204ff381c6b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi all, Since we have discussion for Next PHP, "PHP" namespace discussion would 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. Result: int(3) It's good to use prefered API, but it requires "use" for every function APIs to be overridden. Note: Classes/Interfaces may override by "use" one by one also. With "PHP" and "PHP\Legacy" namespace, user may write: For compatibility, default namespace setting would be nice to have. - None for compiled default - "PHP" for php.ini-* Previous example codes became: 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) namespace. (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 --001a1133c20a8a7ad204ff381c6b--