Re: YANP (Yet Another Namespace Proposal)

From: Date: Sat, 09 Jul 2005 06:39:24 +0000
Subject: Re: YANP (Yet Another Namespace Proposal)
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-17204@lists.php.net to get a copy of this message
For previewing purposes, I have attached a patch of what I have so far so that others can look at it and try it out. I have also attached two PHP files for testing (_testns.php is the script that should be run after the patch is applied. This script includes a class from class3.php to demonstrate two things: namespaces may be spread out in files, and classes do not have to be immediately available for imports to work). I based my patch on PHP 5.1.0b2 (not CVS, yet). I have not used the diff utility before, but here is the command I ran to produce the patch (let me know if there's a better way): diff -Bbruw -X diff_exclude.txt php-5.1.0b2-bak/Zend php-5.1.0b2/Zend/ > ns.patch Anyways, all the features I've mentioned have been enabled in the patch except the following: 1) Automatic including of class files. 2) Wildcard imports (or full namespace imports). I have been checking the code to see what it would take to apply the current include/require logic against a different INI variable (class_path), but I digged deeper and deeper into the code and got lost in the streams functions. So far, it seems I have to create my own opcode (like ZEND_INCLUDE_OR_EVAL), and when that's encountered, then call whatever stream function is needed to perform the include against class_path. It seems like it will take me some time to figure this out, so that's why I haven't included it yet (maybe someone can help me?). Please try it out and let me know what you think. I believe this solution compiles the code to be the equivalent of prefixing all classes, so I think most of the issues presented in the archives are solved with this solution. Let me know if you need anything else from me to get it working on your installation. Also, I'm not sure if there are any attachment restrictions in this group (email me privately if you can't open the files). -- Jessie

Attachment: [application/x-php] _class3.php
Attachment: [text/x-diff] ns.patch
Attachment: [application/x-php] _testns.php
« previous php.internals (#17204) next »